/v1/authorizations/cancelToken
POST /v1/authorizations/cancelToken
With this API call, a merchant can cancel the access token that is obtained from the response of the /v1/authorizations/applyToken API.
Note: After cancellation, the refresh token cannot be used even if it is valid.
Structure
A message consists of a header and body. The following sections are focused on the body structure. For the header structure, see:
Request parameters
Field | Data type | Required | Description | Example |
accessToken | StringĀ | Yes | The access token is used to access user information. For the specific information that can be accessed, see the my.getAuthCode JSAPI.
Note: Obtained this field via the /v1/authorizations/applyToken API. | "281010033AB2F588D14B43238637264FCA5AAF35xxxx" |
extendInfo | String | No | Indicates theĀ extended information about this API.
| copy
|
Response parameters
Field | Data type | Required | Description | Example |
result | Yes | Indicates the request result such as status and error codes. | copy
| |
extendInfo | String | No | Indicates theĀ extended information about this API.
| copy
|
Result process logic
In the response, the result.resultStatus field indicates the result of processing a request. The following table describes each result status:
Result Status | DescriptionĀ |
S | The authorization is canceled successfully. This means that authorized merchants can neither use access token to access user data nor use refresh token to obtain a new access token. The corresponding result.resultCode is |
U | The statusĀ of the authorization cancellation is unknown.Ā The corresponding result.resultCode is For details, see the Common error codes section. |
F | The cancellation of authorization is failed. The authorized merchant may guide the user to try again.Ā The corresponding result.resultCodeĀ and result.resultMessage are various based on different situations.Ā For details, see the followingĀ Error codes section. |
Error codes
Error codes are usually classified into the following categories:
- Common error codes are common for all Mini Program OpenAPIs in V1. Ā
- API-specific error codes are listed in the following table.
Error code | Result status | Error message | Further action |
INVALID_ACCESS_TOKEN | F | The access token is invalid. | Obtain a new access token with refresh token via the /v1/authorizations/applyToken API and then request to cancel the access token again. |
EXPIRED_ACCESS_TOKEN | F | The access token is expired. | Obtain a new access token with refresh token via the /v1/authorizations/applyToken API and then request to cancel the access token again. |
CANCELED_ACCESS_TOKEN | F | The access token is canceled. | Obtain a new access token with refresh token via the /v1/authorizations/applyToken API and then request to cancel the access token again. |
Samples
The data flow to cancel an access token is illustrated as below:
- The user wants to cancel the authorization.
- The mini program sends the cancellation request to the merchant backend.
- The merchant backend calls this API to cancel the authorization with accessToken.
- Then the E-wallet backend processes the request and returns the cancellation result to the merchant server.
- The merchant backend returns the cancellation result to the mini program.
- Finally, the mini program will display the cancellation result to the user.
Request
{
"accessToken": "281010033AB2F588D14B43238637264FCA5AAF35xxxx"
}
The mini program sends a cancellation request to the merchant to cancel the access token (281010033AB2F588D14B43238637264FCA5AAF35xxxx
).
Response
{
"result": {
"resultCode":"SUCCESS",
"resultStatus":"S",
"resultMessage":"success"
}
}
result.resultStatus is S
, which means the request to cancel the access token is successful.