VitalDB APIs use the OAuth2.0 protocol for authentication and authorization.
Your application must request a code and then extracts an access token from the response. Finally, your application can use the data from VitalDB APIs using the access token.
Issue a code, which is required to get an access token. Used in “Sign in with VitalDB” service.
https://vitaldb.net/oauth2/login
GET
| Field | Type |
|---|---|
| client_id | String |
| redirect_uri | String |
| state | String |
| Field | Type | Description |
|---|---|---|
| code | String | A code (random string) which is required to issue an access token. The code will expire in 3 minutes. |
| state | String | Random String used to protect against CSRF (Cross-site Request Forgery). VitalDB server sends back the state parameter. If state parameters are different, CSRF detected. |
curl -i https://vitaldb.net/oauth2/login?client_id=xxxxxxx&redirect_uri=https://www.path-to-redirect.com/callback
Issue an access token which is required to access VitalDB APIs.
https://vitaldb.net/oauth2/token
POST
| Field | Type |
|---|---|
| client_id | String |
| client_secret | String |
| code | String |
OR
| Field | Type |
|---|---|
| id | String |
| pw | String |
| Field | Type | Description |
|---|---|---|
| access_token | String | An access token which is required to access VitalDB APIs |
| token_type | String | Bearer type |
| expires_in | Number | = 3600. The access token expires in an hour. |
curl -v -d 'code=xxxxxxxxxxxx&client_id=xxxxx&client_secret=xxxxxxxx' https://vitaldb.net/oauth2/token
curl -v -d 'id=userid&pw=password' https://vitaldb.net/oauth2/token