Queries the access credential of a device.

Note Each successful call to the GetDeviceCredential operation increases the number of transactions per second (TPS) by one, and therefore you are charged 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 GetDeviceCredential

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

ClientId String Yes GID_test@@@test

The client ID of the device whose access credential you want to query.

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

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

RegionId String Yes cn-hangzhou

The region ID of the Message Queue for MQTT instance.

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

Response parameters

Parameter Type Example Description
DeviceCredential Struct

The access credential of the device.

ClientId String GID_test@@@test

The client ID of the device.

CreateTime Long 1605541382000

The timestamp when the access credential of the device was created. Unit: milliseconds.

DeviceAccessKeyId String DC.Z5fXh9sRRVufyLi6wo****

The AccessKey ID of the device.

DeviceAccessKeySecret String DC.BJMkn4eMQJK2vaApTS****

The AccessKey secret of the device.

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

The ID of the Message Queue for MQTT instance.

UpdateTime Long 1605541382000

The timestamp when the access credential of the device was last updated. Unit: milliseconds.

RequestId String E4581CCF-62AF-44D9-B5B4-D1DQDC0E****

The ID of the request.

Examples

Sample requests

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/? Action=GetDeviceCredential
&ClientId=GID_test@@@test
&InstanceId=post-cn-0pp12gl****
&RegionId=cn-hangzhou
&<Common request parameters>

Sample success responses

XML format

<GetDeviceCredentialResponse>
  <RequestId>E4581CCF-62AF-44D9-B5B4-D1DQDC0E****</RequestId>
  <DeviceCredential>
        <InstanceId>post-cn-0pp12gl****</InstanceId>
        <DeviceAccessKeySecret>DC.BJMkn4eMQJK2vaApTS****</DeviceAccessKeySecret>
        <CreateTime>1605541382000</CreateTime>
        <UpdateTime>1605541382000</UpdateTime>
        <DeviceAccessKeyId>DC.Z5fXh9sRRVufyLi6wo****</DeviceAccessKeyId>
        <ClientId>GID_test@@@test</ClientId>
  </DeviceCredential>
</GetDeviceCredentialResponse>

JSON format

{
    "RequestId": "E4581CCF-62AF-44D9-B5B4-D1DQDC0E****",
    "DeviceCredential": {
        "InstanceId": "post-cn-0pp12gl****",
        "DeviceAccessKeySecret": "DC.BJMkn4eMQJK2vaApTS****",
        "CreateTime": 1605541382000,
        "UpdateTime": 1605541382000,
        "DeviceAccessKeyId": "DC.Z5fXh9sRRVufyLi6wo****",
        "ClientId": "GID_test@@@test"
    }
}

Error codes

HTTP status code Error code Error message Description
404 ApiNotSupport The specified API is not supported. The error message returned because the operation is not supported.
400 ApplyTokenOverFlow You have applied for tokens too many times. Please try again later. The error message returned because token application is too frequent and throttling is triggered by the system. Try again.
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.
500 InternalError An error occurred while processing your request. Try again later. The error message returned because an internal error has occurred to the Message Queue for MQTT instance. Try again.
400 ParameterCheckFailed An error occurred while validating the parameters. The parameters may be missing or invalid. The error message returned because parameter verification failed. This 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.
500 SystemOverFlow An error occurred while processing your request. Please try again. The error message returned because throttling is triggered by the system. Try again.
400 InvalidParameter.%s An error occurred while validating the parameter. The parameter may be missing or invalid. The error message returned because parameter verification failed. This parameter may be missing or invalid.

For a list of error codes, visit the API Error Center.