Welcome to the Protogrid Developer Wiki. A place to gather all the documentation and tips&tricks regarding Protogrid.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
protogrid:json_api_authentication [2017-12-08 17:37]
pgrid_wiki_admin
protogrid:json_api_authentication [2019-12-18 15:51] (current)
jus
Line 52: Line 52:
 response = json.loads(response) response = json.loads(response)
 cookie = req.cookies['​session'​] cookie = req.cookies['​session'​]
 +</​code>​
 +
 +== Request Axios ==
 +Example with Axios
 +<code javascript>​
 +const axios = require('​axios'​);​
 +axios.post('​https://​example.protogrid.com/​api/​v2/​authenticate',​ {}, {
 +  headers: {
 +    '​Content-Type':​ '​application/​json;​ charset=utf-8',​
 +    '​user_email':​ '​test_user@testdomain.com',​
 +    '​user_secret':​ '​test_password'​
 +  }
 +})
 +.then((result) => {
 +  console.log('​Outer Success.'​);​
 +  var cookies_from_resp = res.headers['​set-cookie'​];​
 +  var cookie_for_session = cookies_from_resp[0].split(';'​).[0];​
 +  ​
 +  // send authenticated http request here (see documentation below)
 +})
 +.catch((error) => {
 +  console.error('​Outer Error: ' + error);
 +});
 </​code>​ </​code>​
  
Line 111: Line 134:
 </​code>​ </​code>​
 Note: For more information about the requests, please refer to http://​docs.python-requests.org/​en/​master/​ Note: For more information about the requests, please refer to http://​docs.python-requests.org/​en/​master/​
 +
 +== Example Axios ==
 +Example request with Axios:
 +<code javascript>​
 +axios.get('​https://​example.protogrid.com/​api/​v2/​apps',​ {
 +  headers: {
 +    '​Content-Type':​ '​application/​json;​ charset=utf-8',​
 +    '​Cookie':​ cookie_for_session // The cookie_for_session variable was set above in the authenticate example.
 +  }
 +})
 +.then((result) => {
 +  console.log('​Inner Success.'​);​
 +  console.log(result.data);​
 +})
 +.catch((error) => {
 +  console.log('​Inner Error: ' + error);
 +});
 +</​code>​
  
Print/export