v1

latestOpenAPI 3.0.22026-07-14225376.6 KB
Authorization

Get Access Token

This endpoint only applies to apps using the authorization code flow. An app calls this endpoint to acquire a bearer token once the user has authorized the app. Calls to /oauth2/1/token need to be authenticated using the app's key and secret. These can either be passed as application/x-www-form-urlencoded POST parameters (see parameters below) or via HTTP basic authentication. If basic authentication is used, the app key should be provided as the username, and the app secret should be provided as the password.

post/oauth2/1/token

Request body

Example request

{
  "Get access token using authorization code": {
    "client_id": "ABCDEFG",
    "client_secret": "a123456abcdeghijk7890",
    "code": "ca82123a5476aa2f5e4638957c0ecc55c6ec07c1",
    "code_verifier": "a123456abca",
    "redirect_uri": "https://ndh.digitallocker.gov.in/oauth2-redirect.html"
  },
  "Get access token using device code and OTP": {
    "grant_type": "urn:ietf:params:oauth:grant-type:device_code"
  },
  "Get access token using refresh token": {
    "client_id": "ABCDEFG",
    "client_secret": "a123456abcdeghijk7890",
    "refresh_token": "ca82123a5476aa2f5e4638957c0ecc55c6ec07c1"
  }
}

Response

successful operation

access_tokenstring required

The access token that can be used to call the DigiLocker APIs.

digilocker_idstring required

A unique 36 character DigiLocker Id of the user account.

dobinteger required

This is date of birth of the user as registered with DigiLocker in DDMMYYYY format.

eaadhar'Y' | 'N' required

This indicates whether eAadhaar data is available for this account. Possible values are Y and N.

expires_ininteger required

The duration in seconds for which the access token is valid

gender'M' | 'F' | 'T' required

This is gender of the user as registered with DigiLocker. The possible values are M, F, T for male, female and transgender respectively.

namestring required

The name of the user as registered with DigiLocker.

reference_keystring required

A unique reference of the user account.

refresh_tokenstring required

The refresh token used to refresh the above access token when it expires. Please refer to Refresh Access Token API for more details.

scopestring required

Scope of the token.

token_typestring required

The type of token which will always be Bearer.

Example response

{
  "access_token": "bc125c212a4b03a9a188a858be5a163f379e878a",
  "digilocker_id": "123e4567-e89b-12d3-a456-426655440000",
  "expires_in": 3600,
  "name": "Sunil Kumar",
  "reference_key": "1c66bec26364cd6fefaabc6cae91840a",
  "refresh_token": "a47ab18c593703e4f83a274694db7422a8cfcb8f",
  "token_type": "Bearer"
}