ARIA integration
Aria integration follows docs at http://aria.structuralbiology.eu/docs.html
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).
Step 1 Obtain link
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:
...
<a href="">Import data</a>
...The link is empty and needs to be filled, e.g. using the Fetch API: ariaapi.js:
...
return this.httpclient.fetch('/accessToken.php')
//expecting JSON with {'url':'http://structuralbiology.eu/
// authorize?client_id=123&state=456&response_type=code'}
.then(response => response.json())
.then(data => {
return // use data.url to add it into <a href="${data.url}">get access token</a>
})
...In order not to reveal client_idand 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:
Step 2 Obtain Access Code
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
Step 3 Obtain Access Token
The parameters code and state are used to obtain access token from ARIA proxied by the accessToken.php service ariaapi.js
accessToken.php part 2
Step 4 Get Proposal list
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
Step 5 Get Proposal list
index.js
ariaapi.js
Full working code
Working sample code is in github.com/h2020-westlife-eu/wp6-repository/tree/master/frontend
Last updated