Obtains an access token, which is equivalent to an access permission. The Payment Kit server verifies the token when receiving requests from some APIs.
Protocol: HTTPS POST
Direction: Your server -> Huawei Push Kit server
Data format:
Request: Content-Type: application/x-www-form-urlencoded
Response: Content-Type: application/json;charset=UTF-8
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. |
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 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). |