Last updated
Last updated
Aria integration follows docs at
with slight modification explained in this type of info box
The following steps needs to be performed in order to get proposals from ARIA database: 1. your application needs first generate special link with encrypted client_id and secret_id 2. when user clicks the link, first it is redirected to Instuct site to authenticate and authorize access to the Repository web app. When redirected back, it is redirected with access code and state in url parameters. 3. with access code, web application requests access token. 4. with access token, web application requests list of proposals 5. user can initiate to request proposal detail, it is obtained using access token and proposal ID (pid).
Your application is hosted at http://[yourweb]/index.html. And contains e.g. following link which should initiate importing data on user request.
index.html
:
The link is empty and needs to be filled, e.g. using the Fetch API: ariaapi.js
:
In order not to reveal client_id
and client_secret
, the following code reside on server/backend side only of your application at http:[yourweb]/accessToken.php:
accessToken.php part 1
:
This returns link which can be bind to the HTML by your preffered Javascript framework (Aurelia,Angular,React,Jquery,clean Javascript using DOM api only). So the link is now prepared index.html
:
When the link is clicked by the user, it redirects to Instruct site and user is asked to authorize access to his data to your aplication at [yourweb]. If succesfull, Instruct site will redirect user's browser back to your web using parameters in URL, e.g. http://[yourweb]/index.html?code=789&state=012 Therefore your web application needs to detect parameters in url, e.g. by following code index.js
The parameters code
and state
are used to obtain access token from ARIA proxied by the accessToken.php
service ariaapi.js
PHP7 does not allow credentials in the body of a request. Thus client id and secret is sent as HTTP headers curl_setopt( $ch, CURLOPT_USERPWD, $client_id .':'. $client_secret );
.
accessToken.php part 2
As the web app now has the access_token, it can use it to request ARIA directly (not via accessToken.php). To get user's proposallist and proposal details: index.js
ariaapi.js
Note, the HTTP GET request is used to obtain the proposallist
index.js
ariaapi.js
Note, the HTTP GET request is used to obtain the proposal detail
Working sample code is in