-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
device client register method fails with CredentialError caused by UnauthorizedError when attempting to connect to a device on iot central using python sdk. #709
Comments
The error message that you have received seems to be pointing to one of the 4 values to be wrong.
if you are creating your own device enrollment on the portal (which you can to test it out to see if that works) please follow this The registration id is by default is the device id unless you have chosen those 2 to be different. So please make sure that you are using the correct registration id. And you can also increase your logging level to DEBUG if following the above page still does not work. |
@olivakar, I have used the appropriate values for the registration and connection - with registration_id being the unique device ID as seen in the device connection screen below: I still am facing the same issue. PS: How does one go about increasing the logging level to DEBUG? |
In your python code :-
Additionally if you want to save to a file also add another kwarg Did you try creating a symmetric key individual enrollment record directly on the portal and then trying out the provisioning sample ? I just did with a new enrollment record and everything was fine. If you are able to do that successfully using the same sync sample you should see your enrollment record updated with registration info like this. |
Thanks @olivakar. As I mentioned earlier, we are creating/managing devices on Azure IoT Central. Refer: https://docs.microsoft.com/en-us/azure/iot-central/core/tutorial-connect-device-python We currently don't make use of the Azure IoT Hub service (directly, although I believe Azure IoT Central has it integrated). Here's what we have done - created a device template and then a corresponding device. Applied the device connection information into our python script (provisioning_host, id_scope, registration_id, symmetric_key) and then run the script to be able to register with and connect to the device instance created to push telemetry data. The only difference between the sample app in the reference and what we have used is that we have modified it to be synchronous using an example available in the azure-iot-sdk-python specifically this. Here's the console log after logging level at DEBUG (based on the changes suggested by you to this effect):
|
I was able to follow the steps in the tutorial and create device, provision device and also send telemetry. |
The provisioning host is set to 'global.azure-devices-provisioning.net' as suggested in the tutorial. |
Hi @avwater , unfortunately we are unable to repro this issue with the tutorial. We will work with Satish (from your Microsoft Q&A post) to communicate with you and find a root cause. For now, let's use that channel. We'll leave this open in the meantime and return to it when we have a solution. |
Closing this issue as it was resolved on a separate thread. Please reopen if there are still issues, thank you! |
@avwater, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey |
Can you please post the resolution or a link to the thread? I've just followed the tutorial (running python3.7 in WSL) and am having the same issue. |
For anyone else - the exact same code (with hardcoded parameters) works in Windows command prompt, and not Ubuntu WSL. Should I file this as a bug or is it a know issue @olivakar ? |
@kodonnell , thanks for following up on this! Could you please file the issue with WSL? that is not a known bug to my knowledge, and we will coordinate with the IoT Central team. The initial resolution was having the appropriate roles set (need to be an application Administrator), but it sounds like your issue may be different. Here's a verbatim explanation for this issue: _To access and use the Administration section, you must be in the Administrator role for an Azure IoT Central application. If you create an Azure IoT Central application, you're automatically added to the Administrator role for that application. For more information, see Manage users and roles in Azure IoT Central application. You can either create your own IoT Central application for testing and to run the tutorial, in which case you'll be in Administrator role automatically. Or, you can ask someone who is in the Administrator role for your application to retrieve the group SAS key for you._ |
Context
Description of the issue
We are attempting to check if we can push telemetry data onto a device created in Azure IoT Central by following the tutorial:
https://docs.microsoft.com/en-us/azure/iot-central/core/tutorial-connect-device-python
On running the environmental_sensor.py that we created, we were hit with the following message:
We then modified the script to be a sync version of the same using:
https://github.com/Azure/azure-iot-sdk-python/blob/master/azure-iot-device/samples/sync-samples/provision_symmetric_key.py
as reference.
Upon running the environmental_sensor.py, we encountered the following error:
Code sample exhibiting the issue
Here's the modified script that we used. All it does is register, connect and attempt to send telemetry every 5s - synchronously.
sync_env_sensor.txt
Console log of the issue
This issue has also been raised @ https://docs.microsoft.com/en-us/answers/questions/154410/device-client-register-method-fails-with-credentia.html
Any help will be greatly appreciated.
AB#8828384
The text was updated successfully, but these errors were encountered: