目录

Obtaining an App-Level Credential

Obtains an access token, which is equivalent to an access permission. The Payment Kit server verifies the token when receiving requests from some APIs.

Prototype

Request Parameters

Request Header

Parameter Mandatory Type Description
Content-Type Yes String Content type. The value is application/x-www-form-urlencoded.

Request Body

Parameter Mandatory Type Description
grant_type Yes String Permission grant mode. Set this parameter to client_credentials, which indicates the client credential mode.
client_id Yes String OAuth 2.0 client ID of the app. On AppGallery Connect, click Development and services, find the project in the project list, choose Project settings > General information, and obtain the value of OAuth 2.0 client ID > Client ID in the App information area.
client_secret Yes String Key allocated to the OAuth 2.0 client ID of the app. On AppGallery Connect, click Development and services, find the project in the project list, choose Project settings > General information, and obtain the value of OAuth 2.0 client ID > Client secret in the App information area.

Request Example

POST /oauth2/v3/token?grant_type=client_credentials&client_id=<Client ID>&client_secret=<Client key> HTTP/1.1
Content-Type: application/x-www-form-urlencoded

Response Parameters

Response Header

Parameter Mandatory Type Description
Content-Type Yes String The value is application/json;charset=UTF-8.

Response Body

Parameter Mandatory Type Description
token_type Yes String Token type. The value is always Bearer.
access_token Yes String Access token, which is the app-level credential.
expires_in No Long Access token validity period, in seconds. The default value is 3600 seconds (that is, 60 minutes).

Response Example

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
{
  "access_token": "<Returned access token>",
  "expires_in": 3600,
  "token_type": "Bearer"
}