Azure / azure-iot-arduino

Azure IoT library for the Arduino
Other
168 stars 95 forks source link

SAS Token problem #74

Closed KoRba88 closed 4 years ago

KoRba88 commented 6 years ago

Hi

My code compiled but from serial monitor i have get this messeges

Func:Base64_Decoder Line:201 Invalid length Base64 string! Func:construct_sas_token Line:217 Unable to decode the key for generating the SAS. Func:IoTHubClient_Auth_Get_SasToken Line:388 Failed creating sas_token Func:SendMqttConnectMsg Line:1696 failure getting sas token from IoTHubClient_Auth_Get_SasToken.

Info: Sending sensor value Temperature = 32, Humidity = 19

Info: IoTHubClient accepted the message for delivery

And its repeating

Also I see is that nothing appears in my IoTHub.

I have double checked the Hostname, Device Id & Device Key and they are OK.

Whats wrong?

Best Regards KoRba88

JetstreamRoySprowl commented 6 years ago

That complaint is pointing strongly at an incorrectly formatted connection string. Have you gotten it to work yet?

Tathagatd96 commented 5 years ago

Did you find a solution to this problem. I am facing the same issue and cannot get it to work.

Thanks for the help

satyak5 commented 5 years ago

It's been a while since I used it but check your connection string. It's coz of my connection string that throwed me an error

On Wed, Dec 12, 2018 at 11:48 AM Tathagatd96 notifications@github.com wrote:

Did you find a solution to this problem. I am facing the same issue and cannot get it to work.

Thanks for the help

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Azure/azure-iot-arduino/issues/74#issuecomment-446475780, or mute the thread https://github.com/notifications/unsubscribe-auth/AiW1x7k81QQ3jd6p31WNE0gaZZeQ7gDBks5u4J-0gaJpZM4SJpI5 .

-- Sent from MetroMail

Tathagatd96 commented 5 years ago

I am directly copying the connection string from my azure portal, it's still throwing me an error. Do we have to copy in the entire string or just the shared access part?

satyak5 commented 5 years ago

I am really sorry bruh !I forgot actually. i used to work on that a year back and now i am into web development. I wish i could have helped you. Copy connection string from device explorer. That will work i guess

On Wed, Dec 12, 2018 at 12:09 PM Tathagatd96 notifications@github.com wrote:

I am directly copying the connection string from my azure portal, it's still throwing me an error. Do we have to copy in the entire string or just the shared access part?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Azure/azure-iot-arduino/issues/74#issuecomment-446479431, or mute the thread https://github.com/notifications/unsubscribe-auth/AiW1x4KrQdryhUrr6iq_SKIMzrEx2At9ks5u4KSUgaJpZM4SJpI5 .

foote commented 5 years ago

Anyone come up with a solution for this? 2019-05-20 01:06:56 ERROR: base64_utility.c (ln 201): Invalid length Base64 string! 2019-05-20 01:06:56 ERROR: sastoken.c (ln 217): Unable to decode the key for generating the SAS. 2019-05-20 01:06:56 ERROR: iothub_client_authorization.c (ln 460): Failed creating sas_token 2019-05-20 01:06:56 ERROR: iothubtransport_mqtt_common.c (ln 2169): failure getting sas token from IoTHubClient_Auth_Get_SasToken.

simf1 commented 5 years ago

Hi foote, Did you resolve your issue?

I have the same error as you have, when my IoTDevKit is connected to the wifi. It repeats the message no-stop.

I fallowed the step-by-step Microsoft Procedure "GetStarted - Connect IoT DevKit AZ3166 to Azure IoT Hub"

I took the ConnectionString from this command: az iot hub device-identity show-connection-string --hub-name YourIoTHubName --device-id MyNodeDevice --output table

I tried with the connection located in Iot Device Explorer... and same result.

And i used this connection string format: HostName={YourIoTHubName}.azure-devices.net;DeviceId=MyNodeDevice;SharedAccessKey={YourSharedAccessKey}

This is the ERROR: 2019-08-28 13:22:04 ERROR: base64_utility.c (ln 201): Invalid length Base64 string! 2019-08-28 13:22:04 ERROR: sastoken.c (ln 217): Unable to decode the key for generating the SAS. 2019-08-28 13:22:04 ERROR: iothub_client_authorization.c (ln 460): Failed creating sas_token 2019-08-28 13:22:04 ERROR: iothubtransport_mqtt_common.c (ln 2169): failure getting sas token from IoTHubClient_Auth_Get_SasToken.

The screen of my IoTDevKit still with the IP Adress and Running... (under that, " > IoT Hub")

Did you find a solution for that? My connection string contains 112 characters (with the label HostName=, and ... all worked fine the first day that I tried. The next day... this issue appears.)

# version DevKitSDK version: 1.6.2 Mico version: 31620002.049 mbed-os version: 5.4.3 mbed TLS version: 2.15.0 WIFI version: wl0: Sep 10 2014 11:28:46 version 5.90.230.10

2019-08-28 09_27_04-Window 2019-08-28 09_21_43-COM5 - PuTTY

jbobotek commented 4 years ago

This issue has not received any responses for quite some time. Closing. If you continue to experience issues, please open a new issue.