Updates the access credential of a device.

Limits

You can call this API operation up to 500 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limits.

Note You are charged for successful calls to the RefreshDeviceCredential operation. Each successful call increases the number of transactions per second (TPS) by one. 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

ParameterTypeRequiredExampleDescription
ActionStringYesRefreshDeviceCredential

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

ClientIdStringYesGID_test@@@test

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

InstanceIdStringYespost-cn-0pp12gl****

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

RegionIdStringYescn-hangzhou

The region ID of the ApsaraMQ for MQTT instance.

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

Response parameters

ParameterTypeExampleDescription
DeviceCredentialStruct

The access credential of the device.

ClientIdStringGID_test@@@test

The client ID of the device.

CreateTimeLong1605541382000

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

DeviceAccessKeyIdStringDC.Z5fXh9sRRVufyLi6wo****

The AccessKey ID of the device.

DeviceAccessKeySecretStringDC.BJMkn4eMQJK2vaApTS****

The AccessKey secret of the device.

InstanceIdStringpost-cn-0pp12gl****

The ID of the ApsaraMQ for MQTT instance.

UpdateTimeLong1605541382000

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

RequestIdStringE4581CCF-62AF-44D9-B5B4-D1DBDC0F****

The ID of the request.

Examples

Sample requests

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

Sample success responses

XML format

<RefreshDeviceCredentialResponse>
  <RequestId>E4581CCF-62AF-44D9-B5B4-D1DBDC0F****</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>
</RefreshDeviceCredentialResponse>

JSON format

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

Error codes

HttpCodeError codeError messageDescription
404ApiNotSupportThe specified API is not supported.The error message returned because the operation is not supported.
400ApplyTokenOverFlowYou have applied for tokens too many times. Please try again later.The error message returned because tokens are frequently requested and throttling is triggered. Try again later.
400CheckAccountInfoFailedAn 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.
400InstancePermissionCheckFailedAn 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 your account failed the verification of the permissions on the ApsaraMQ for MQTT instance. Check the ownership and authorization policy of the instance.
500InternalErrorAn error occurred while processing your request. Try again later.The error message returned because the backend service of the ApsaraMQ for MQTT instance is abnormal. Try again.
400ParameterCheckFailedAn 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.
400PermissionCheckFailedAn 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 your account failed the verification of the permissions on the specified resources. Check the ownership and authorization policies of the specified instance, topic, and group.
500SystemOverFlowAn error occurred while processing your request. Please try again.The error message returned because throttling is triggered. Try again.
400InvalidParameter.%sAn 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.

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