Query Details About an Authentication Template
Function
The API is used by an application to query details about a device authentication template with a specified ID on the IoT platform.
Debugging
You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.
Authorization Information
Each account has all the permissions required to call all APIs, but IAM users must be assigned the required permissions.
- If you are using role/policy-based authorization, see Permissions Policies and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
Action
Access Level
Resource Type (*: required)
Condition Key
Alias
Dependencies
iotda:deviceauthenticationtemplate:query
Read
instance *
g:EnterpriseProjectId
-
-
URI
GET /v5/iot/{project_id}/device-authentication-templates/{template_id}
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
project_id |
Yes |
String |
Parameter description: project ID. For details, see Obtaining a Project ID. |
|
template_id |
Yes |
String |
Authentication template ID. |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
No |
String |
Parameter description: user token. Obtain the token by calling the IAM API for obtaining a user token through password authentication. In the returned response header, X-Subject-Token is the desired user token. For details about how to obtain the token, see Token Authentication. |
|
Instance-Id |
No |
String |
Parameter description: instance ID. This parameter is required only when the API is called from the management plane in the physical multi-tenant scenario. Log in to the IoTDA console and choose Overview in the navigation pane to check the instance ID. |
Response Parameters
Status code: 200
|
Parameter |
Type |
Description |
|---|---|---|
|
template_id |
String |
Authentication template ID. |
|
template_name |
String |
Authentication template name. |
|
create_time |
String |
Time when an authentication template is created. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
|
update_time |
String |
Time when the authentication template was last modified. The value is in the format of yyyyMMdd'T'HHmmss'Z', for example, 20151212T121212Z. |
|
description |
String |
Description of an authentication template. |
|
status |
String |
Parameter description: authentication template status.
|
|
template_body |
AuthenticationTemplateBody object |
Parameter description: details of a pre-provisioning template, in JSON format. |
|
Parameter |
Type |
Description |
|---|---|---|
|
parameters |
Object |
Parameter description: authentication template parameters. The clientId, username, and device certificate attributes in the MQTT connection parameters are preset on the platform.
|
|
resources |
Structure of device resource details in the authentication template. |
|
Parameter |
Type |
Description |
|---|---|---|
|
device_id |
Object |
Device ID. The JSON object can obtain the device ID from parameters only by using the function under FunctionDefinition. |
|
timestamp |
TimestampResource object |
Verification of the device timestamp is conducted if the value is not empty. Recommended: Enable verification if the device connection parameters (clientId and username) include the timestamp. Verification process: The platform compares the timestamp carried by the device with the platform system time. If the timestamp plus 1 hour is less than the platform system time, the verification fails. To disable the verification, set value to {}. |
|
password |
Object |
The MQTT authentication password is required for password authentication mode, not for certificate authentication mode. To generate the password from the parameters, use the FunctionDefinition function. The platform verifies that the parsed function result matches the MQTT connection password for successful authentication. The function must contain the device original secret parameter ${iotda::device::secret} and can be used only in the hash function. |
|
Parameter |
Type |
Description |
|---|---|---|
|
type |
String |
UNIX: Unix timestamp, which is a long integer at the second level. FORMAT: time format specified in the format field. |
|
pattern |
String |
Date and time format. |
|
value |
Object |
Timestamp of the device connection. You can use the FunctionDefinition function to generate the timestamp. To disable timestamp verification, leave this field empty ({}). |
Example Requests
Queries details about an authentication template with a specified ID.
GET https://{endpoint}/v5/iot/{project_id}/device-authentication-templates/{template_id}
Example Responses
Status code: 200
OK
{
"template_id" : "5c90fa7d3c4e4405e8525079",
"template_name" : "myTemplate",
"description" : "myTemplate",
"status" : "ACTIVE",
"template_body" : {
"parameters" : {
"iotda::mqtt::client_id" : {
"type" : "String"
},
"iotda::mqtt::username" : {
"type" : "String"
},
"iotda::device::secret" : {
"type" : "String"
}
},
"resources" : {
"device_id" : {
"Fn::SplitSelect" : [ "${iotda::mqtt::username}", "&", 0 ]
},
"timestamp" : {
"type" : "UNIX",
"value" : {
"Fn::MathDiv" : [ {
"Fn::ParseLong" : {
"Fn::SplitSelect" : [ {
"Fn::SplitSelect" : [ "${iotda::mqtt::client_id}", "|", 2 ]
}, "=", 1 ]
}
}, 1000 ]
}
},
"password" : {
"Fn::HmacSHA256" : [ {
"Fn::Sub" : [ "clientId${clientId}deviceName${deviceName}productKey${productKey}timestamp${timestamp}", {
"clientId" : {
"Fn::SplitSelect" : [ "${iotda::mqtt::client_id}", "|", 0 ]
},
"deviceName" : {
"Fn::SplitSelect" : [ "${iotda::mqtt::username}", "&", 0 ]
},
"productKey" : {
"Fn::SplitSelect" : [ "${iotda::mqtt::username}", "&", 1 ]
},
"timestamp" : {
"Fn::SplitSelect" : [ {
"Fn::SplitSelect" : [ "${iotda::mqtt::client_id}", "|", 2 ]
}, "=", 1 ]
}
} ]
}, "${iotda::device::secret}" ]
}
}
},
"create_time" : "20230810T070547Z",
"update_time" : "20230810T070547Z"
}
Status Codes
|
Status Code |
Description |
|---|---|
|
200 |
OK |
|
404 |
Not Found |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot