Verifies the validity of a token.

Scenarios

This operation is called by an application server to check whether a single token is valid. For more information, see Overview of token-based authentication.

Limits

A user can send up to 100 requests per second. If you want to increase the limit on the number of requests that a user can send per second, join the DingTalk group 35228338 to contact Message Queue for MQTT technical support.

Note Each successful call to the QueryToken operation is calculated as a message transaction per second (TPS). This way, you are billed for the call. For more information, see Billing.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes QueryToken

The operation that you want to perform. Set the value to QueryToken.

Token String Yes LzMT+XLFl5s/YWJ/MlDz4t/Lq5HC1iGU1P28HAMaxYxn8aQbALNtml7QZKl9L9kPe6LqUb95tEVo+zUqOogs9+jZwDUSzsd4X4qaD3n2TrBEuMOqKkk1Xdrvu9VBQQvIYbz7MJWZDYC3DlW7gLEr33Cuj54iIhagtBi3epStJitsssWs7otY9zhKOSZxhr49G3d0bh35mwyP18EMvDas8UlzeSozsSrujNUqZXOGK0PEBSd+rWMGDJlCt6GFmJgm2JFY7PJwf/7OOSmUYIYFs5o/PuPpoTMF+hcVXMs+0yDukIMTOzG9m3t8k36PVrghFmnK6pC3Rt3mibjW****ng==

The token that you want to query.

InstanceId String Yes post-cn-0pp12gl****

The ID of the Message Queue for MQTT instance. The value must be the same as the instance ID that is used by the Message Queue for MQTT client. You can obtain the instance ID on the Instance Details page in the Message Queue for MQTT console.

Note For more information about parameters, see Common parameters and Endpoints.

Response parameters

Parameter Type Example Description
TokenStatus Boolean true

The status of the token that you queried. Valid values:

  • true: indicates the token is valid.
  • false: indicates the token is invalid.
RequestId String 5C8AADD0-6A95-436D-AFA0-3405CCE3****

The ID of the request. This parameter is a common parameter. Each request has a unique ID.

Examples

Sample requests

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryToken
&InstanceId=post-cn-0pp12gl****
&RegionId=cn-hangzhou
&Token=LzMT+XLFl5s/YWJ/MlDz4t/Lq5HC1iGU1P28HAMaxYxn8aQbALNtml7QZKl9L9kPe6LqUb95tEVo+zUqOogs9+jZwDUSzsd4X4qaD3n2TrBEuMOqKkk1Xdrvu9VBQQvIYbz7MJWZDYC3DlW7gLEr33Cuj54iIhagtBi3epStJitsssWs7otY9zhKOSZxhr49G3d0bh35mwyP18EMvDas8UlzeSozsSrujNUqZXOGK0PEBSd+rWMGDJlCt6GFmJgm2JFY7PJwf/7OOSmUYIYFs5o/PuPpoTMF+hcVXMs+0yDukIMTOzG9m3t8k36PVrghFmnK6pC3Rt3mibjW****ng==
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<QueryTokenResponse>
<RequestId>5C8AADD0-6A95-436D-AFA0-3405CCE3****</RequestId>
<TokenStatus>true</TokenStatus>
</QueryTokenResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "5C8AADD0-6A95-436D-AFA0-3405CCE3****",
  "TokenStatus" : true
}

Error codes

HttpCode Error code Error message Description
400 CheckAccountInfoFailed An error occurred while checking the account information by the STS token. The error message returned because the account information of the Security Token Service (STS) token failed to be parsed.
400 InstancePermissionCheckFailed An error occurred while validating the permissions of the instance. Please verify the account that created the instance and its permissions settings. The error message returned because instance permission verification failed. Check the ownership and authorization policy of the Message Queue for MQTT instance.
400 ParameterCheckFailed An error occurred while validating the parameters. The parameters may be missing or invalid. The error message returned because the parameter failed to be verified. The parameter may be missing or invalid.
400 PermissionCheckFailed An error occurred while validating the resource permissions. Please check the account that created the instance, topic, and GroupId, and check their permission settings. The error message returned because resource permission verification failed. Check the permissions and authorization policies of the instance, topic, and group ID.
400 QueryTokenOverFlow You have queried tokens too many times. Please try again later. The error message returned because token query is too frequent and throttling is triggered by the system. Try again later.
400 InvalidParameter.%s An error occurred while validating the parameter. The parameter may be missing or invalid. The error message returned because the parameter failed to be verified. The parameter may be missing or invalid.
500 InternalError An error occurred while processing your request. Try again later. The error message returned because a backend service error occurred to the Message Queue for MQTT instance. Try again.
500 SystemOverFlow An error occurred while processing your request. Please try again. The error message returned because throttling is triggered. Try again.
404 ApiNotSupport The specified API is not supported. The error message returned because the API operation is not supported.

For a list of error codes, see Service error codes.