0
votes

i want use azure Device Identities REST API to create devices identity :https://msdn.microsoft.com/en-us/library/azure/mt548489.aspx but i don't know the syntaxe to set in header request ? what is the key and how to generate value ? here is the param :

  • Set the Authorization header to a SAS token created as specified in the service section of Using IoT Hub security tokens.
  • The Etag header is returned in all requests scoped to a single device identity, as per RFC7232 .

Thanks

2

2 Answers

1
votes

As @DominicBetts said, you can refer to the referenced document to generate the SAS token by yourself.

As reference, there is not an existing sample code for Java, but I think you can try to refer to the offical sample for Python to knwo how to use the device identities REST API, please see the sample at https://azure.microsoft.com/en-us/documentation/samples/iot-hub-python-get-started/ and download the sample zip file to see the script service/deviceManager.py.

Meanwhile, you can also try to directly read the source code of IoTHub SDK for Java. For generating the SAS token, please see the code at https://github.com/Azure/azure-iot-sdks/blob/master/java/service/iothub-service-sdk/src/main/java/com/microsoft/azure/iot/service/auth/IotHubServiceSasToken.java.

0
votes

Please take a look here: https://azure.microsoft.com/documentation/articles/iot-hub-sas-tokens/#using-security-tokens-from-service-components

This article explains how you can generate the security token you need - in particular the section "Using security tokens from service components".