/v1/authorizations/cancelToken

POST /v1/authorizations/cancelToken

The cancelToken API is used to cancel access token at wallet.

Message structure

Request

Property

Data type

Required

Description

accessToken

String

Yes

An access token that can be used to access the user resource scope.

Max. length: 128 characters.

Response

Property

Data type

Required

Description

result

Result

Yes

The request result, which contains information related to the request result, such as status and error codes.

Result process logic

For different request results, different actions are to be performed. See the following list for details:

  • If the value of result.resultStatus is S, that means the authorization is cancelled successfully. AuthClient will not be able to use the AccessToken to access user's resources, and may not use the relative refreshToken to retrieve new AccessToken.
  • If the value of result.resultStatus is F or U, that means authorization is cancelled failed, AuthClient may guide user to try again.

Result

resultStatusresultCoderesultMessage
SSUCCESSSuccess.
UUNKNOWN_EXCEPTIONAn API calling is failed, which is caused by unknown reasons.
UREQUEST_TRAFFIC_EXCEED_LIMITThe request traffic exceeds the limit.
FPROCESS_FAILA general business failure occurred. Don't retry.
FPARAM_ILLEGALIllegal parameters exist. For example, a non-numeric input, or an invalid date.
FACCESS_DENIEDThe access is denied.
FINVALID_APIThe called API is invalid or not active.
FINVALID_AUTH_CLIENT_STATUS

Invalid auth client status.

FINVALID_ACCESS_TOKENThe access token is invalid.
FINVALID_AUTH_CLIENTThe auth client id is invalid. 
FEXPIRED_ACCESS_TOKENThe access token is expired.

F

EXPIRED_AGENT_TOKEN

The access token of mini program is expired.

F

INVALID_AGENT_TOKEN

The access token of mini program is invalid.

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

UNKNOWN_EXCEPTION

U

API failed due to unknown reason.

Check logs for related errors and contact the appropriate personnel.

PARAM_ILLEGAL

F

Illegal parameters.

Validate and correct input parameters, then retry.

INVALID_AUTH_CLIENT

F

The auth client id is invalid.

Have the merchant re-sign the product contract (StandardDirectPay) and configure the client ID.

INVALID_ACCESS_TOKEN

F

The access token is invalid.

Obtain a new authorization code via the my.getAuthCode JSAPI and then get a valid access token with the authorization code via the /v1/authorizations/applyToken API.

CANCELED_ACCESS_TOKEN

F

The access token is canceled.

The access token is canceled and no further operation is required.

ACCESS_TOKEN_NOT_COVER_THE_SCOPE

F

The access token permission scope does not contain specified scope.

Check the product contract (StandardDirectPay) and configure the corresponding scope.

EXPIRED_ACCESS_TOKEN

F

The access token is expired.

Obtain a new access token with a refresh token via the /v1/authorizations/applyToken API.

Sample

You can cancel the authorization. After cancellation, the refresh_token cannot be used even if it is valid.

/v1/authorizations/cancelToken

When user cancel access token from the Mini Program,

  1. The Merchant server calls /v1/authorizations/cancelToken interface to cancel access token (Step 2).
  2. And wallet server returns token cacnel result to merchant server (Step 3).

Request

copy
{
  "accessToken": "281010033AB2F588D14B43238637264FCA5Axxxx",
}

Response

copy
{
 "result": {
    "resultCode":"SUCCESS",
    "resultStatus":"S",
    "resultMessage":"success"
  }
}