OAuth2 API

Introduction

VitalDB APIs use the OAuth2.0 protocol for authentication and authorization.

Overall Process

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.

Login Page

Issue a code, which is required to get an access token. Used in “Sign in with VitalDB” service.

Endpoint

https://vitaldb.net/oauth2/login

Method

GET

Parameters

Field Type
client_id String
redirect_uri String
state String

Return Value

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.

Sample Codes

curl -i https://vitaldb.net/oauth2/login?client_id=xxxxxxx&redirect_uri=https://www.path-to-redirect.com/callback

Get Token

Issue an access token which is required to access VitalDB APIs.

Endpoint

https://vitaldb.net/oauth2/token

Method

POST

Parameters

Field Type
client_id String
client_secret String
code String

OR

Field Type
id String
pw String

Return Value

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.

Sample Codes

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