Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
protogrid:json_api_authentication [2022-02-22 00:12] – dru | protogrid:json_api_authentication [2022-02-22 23:09] (current) – [/api/v2/authenticate] dru | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== JSON API Authentication ====== | ====== JSON API Authentication ====== | ||
- | All HTTP requests to the Protogrid JSON API require a valid authentication. If the authentication fails an HTTP error 403 will be returned. The following variants are available for authentication: | + | All HTTP requests to the Protogrid JSON API require a valid authentication. If the authentication fails an HTTP error 403 will be returned. |
+ | |||
+ | The following variants are available for authentication | ||
* Header authentication using the HTTP headers ' | * Header authentication using the HTTP headers ' | ||
* [[https:// | * [[https:// | ||
- | * Cookie authentication | + | * Cookie authentication |
Note: Both the email address (e.g. " | Note: Both the email address (e.g. " | ||
- | ==== / | + | ===== / |
[POST] In order to obtain a session cookie you can use the authentication endpoint. | [POST] In order to obtain a session cookie you can use the authentication endpoint. | ||
- | For this endpoint, in addition to the three variants above, the credentials can also be passed as JSON in the request body: | + | Note: For this endpoint, in addition to the three variants above, the credentials can also be passed as " |
<code javascript> | <code javascript> | ||
{ | { | ||
Line 18: | Line 20: | ||
</ | </ | ||
- | ==== Examples | + | ===== Examples |
- | === HTTP === | + | ==== HTTP ==== |
< | < | ||
POST / | POST / | ||
Line 28: | Line 30: | ||
</ | </ | ||
- | === jQuery === | + | ==== jQuery |
<code javascript> | <code javascript> | ||
$.ajax({ | $.ajax({ | ||
Line 42: | Line 44: | ||
</ | </ | ||
- | === Python === | + | ==== Python |
<code python> | <code python> | ||
import requests | import requests | ||
Line 53: | Line 55: | ||
</ | </ | ||
- | === Axios === | + | ==== Axios ==== |
<code javascript> | <code javascript> | ||
const axios = require(' | const axios = require(' | ||
Line 75: | Line 77: | ||
</ | </ | ||
- | === Success Response === | + | ==== Success Response |
Example response of successful authentication: | Example response of successful authentication: | ||
<code javascript> | <code javascript> | ||
Line 85: | Line 87: | ||
</ | </ | ||
- | === Error Response === | + | ==== Error Response |
Example response of unsuccessful authentication: | Example response of unsuccessful authentication: | ||
<code javascript> | <code javascript> | ||
Line 100: | Line 102: | ||
</ | </ | ||
- | ==== Example HTTP requests | + | ===== Examples |
- | === HTTP === | + | ==== HTTP ==== |
< | < | ||
GET / | GET / | ||
Line 109: | Line 111: | ||
</ | </ | ||
- | === jQuery === | + | ==== jQuery |
<code javascript> | <code javascript> | ||
$.ajax({ | $.ajax({ | ||
Line 128: | Line 130: | ||
In particular, this means that you usually don't need to worry about authentication if you use JSON API requests in [[protogrid: | In particular, this means that you usually don't need to worry about authentication if you use JSON API requests in [[protogrid: | ||
- | === Python === | + | ==== Python |
<code python> | <code python> | ||
# The cookie variable was set above in the authentication example. | # The cookie variable was set above in the authentication example. | ||
Line 138: | Line 140: | ||
For more information about the requests library, please refer to [[http:// | For more information about the requests library, please refer to [[http:// | ||
- | === Axios === | + | ==== Axios ==== |
<code javascript> | <code javascript> | ||
axios.get(' | axios.get(' |