All Products
Search
Document Center

Identity as a Service:GenerateToken

Last Updated:Sep 10, 2024

Generates a token for accessing an application in an instance.

Operation description

Note
  • The following authorization types are supported: authorization code, device code, refresh token, and client credentials.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

POST /v2/{instanceId}/{applicationId}/oauth2/token

Request parameters

ParameterTypeRequiredDescriptionExample
instanceIdstringYes

The instance ID.

idaas_ue2jvisn35ea5lmthk267xxxxx
applicationIdstringYes

The application ID.

app_mkv7rgt4d7i4u7zqtzev2mxxxx
client_idstringNo

The client ID.

app_mkv7rgt4d7i4u7zqtzev2mxxxx
client_secretstringNo

The client secret. This parameter is required if grant_type is set to client_credentials.

CSEHDcHcrUKHw1CuxkJEHPveWRXBGqVqRsxxxx
grant_typestringYes

The authorization type. Valid values:

  • authorization_code
  • urn:ietf:params:oauth:grant-type:device_code
  • refresh_token
  • client_credentials: You must specify the client_id and client_secret parameters.
  • password: This option is not supported.
client_credentials
codestringNo

The authorization code. This parameter is required if grant_type is set to authorization_code.

xxxx
usernamestringNo

The username. This parameter is required if grant_type is set to password. The password authentication type is not supported.

uesrname_001
passwordstringNo

The username. This parameter is required if grant_type is set to password. The password authentication type is not supported.

xxxxxx
device_codestringNo

The device code. This parameter is required if grant_type is set to authorization_code.urn:ietf:params:oauth:grant-type:device_code.

xxxx
redirect_uristringNo

The redirect URI. This parameter is required if grant_type is set to authorization_code. The value of this parameter must be the same as the redirect URI in the request to obtain the authorization code.

xxx
refresh_tokenstringNo

The refreshed token. This parameter is required if grant_type is set to refresh_token.

ATxxx
code_verifierstringNo

The verification code.

xxx
exclusive_tagstringNo

The excluded tags.

ATxxx
scopestringNo

The authorization scope. Valid values:

  • openid
  • email
  • phone
  • profile
xxxx

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

token_typestring

The type of the token. Valid values: Basic Bearer

Bearer
access_tokenstring

The access token.

ATxxx
refresh_tokenstring

The refresh token.

RTxxx
expires_inlong

The remaining validity period of the token. Unit: seconds.

1200
expires_atlong

The time when the token expires. This value is a UNIX timestamp representing the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC.

1653288641
id_tokenstring

The ID token.

xxxxx

Examples

Sample success responses

JSONformat

{
  "token_type": "Bearer",
  "access_token": "ATxxx",
  "refresh_token": "RTxxx",
  "expires_in": 1200,
  "expires_at": 1653288641,
  "id_token": "xxxxx"
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-10-24The internal configuration of the API is changed, but the call is not affectedView Change Details
2023-04-04The internal configuration of the API is changed, but the call is not affectedView Change Details