Debugging 401 Error Response

I have 2 MakerApp setups that are working. I have a 3rd one that is driving me crazy. I have turned on logging but I get nothing that helps. I have created an Illuminance virtual device. I have a Raspberry Pi that has a light sensor and provides illuminance values in lux. I am using "Send Device Command" to send the value to Hubitat. Below is the information provided in the App:
Send Device Command (replace [Device ID] with actual subscribed device id and [Command] with a supported command. Supports optional [Secondary value])
xttp://10.107.1.135/apps/api/256/devices/[Device ID]/[Command]/[Secondary value]?access_token=0cf4bdfe-310c-4d40-861a-366eb204bdd2

Below is the device information provided in response to the query:
[{"name":"Virtual Illuminance Sensor","label":"Sky Light","type":"Virtual Illuminance Sensor","id":"218",
"date":"2024-03-29T19:27:40+0000","model":null,"manufacturer":null,"room":"Outside",
"capabilities":["IlluminanceMeasurement"],"attributes":{"illuminance":"100","dataType":"NUMBER","values":null},
"commands":[{"command":"setLux"}]}]

Below is the text of the HTTP Get that is being sent from the Pi and the response:
xttp://10.107.1.135/apps/api/256/devices/218/setLux/24?0cf4bdfe-310c-4d40-861a-366eb204bdd2
<Response [401]>

Obviously, I'm overlooking something simple. Can I get the API to log information that will explain the problem? Thanks in advance for any help. (I changed the URL to be able to post the link.)

Well... 401 is explaining your problem.
It means you are unauthorized to make the request.
Something in your access token or perhaps app.
Is this a custom app? Do you need to enable oauth in the app?

Also, is your PI request correct?
Should it not have the "access_token=" parameter?

This:
xttp://10.107.1.135/apps/api/256/devices/218/setLux/24?XXXX-XX-XX-XXXX

Should be this:
xttp://10.107.1.135/apps/api/256/devices/218/setLux/24?access_token=XXXX-XX-XX-XXXX

2 Likes

@ghoff50 @joshlobe - may want to redact the access_token value in the posts above

3 Likes

You're absolutely correct.
I figured if it was posted here, it would be re-created, just out of caution.
Yes, @ghoff50, let's redact the tokens, and you need to re-create on your end.
Thanks.

1 Like

You are absolutely correct. I copied the code from one of my other apps and somehow I did not spot the missing keyword. I feel stupid but relieved. I will, of course, generate a new access token.

2 Likes

Lol. We've all been there at one point or another :slight_smile:
Just the other day, I was trying to figure out why one of my Sonos speakers quit working. I sat at the computer for 3 hours, debugging, testing, sending data... nothing. I walked over to the speaker, and my cleaner had accidentally unplugged it while cleaning, and didn't plug it back in...

Yeah... I felt real great after that realization...

1 Like

I just wanted to say also; KUDOS for submitting a proper ticket.
It was easy to follow, had all the necessary data, and was well organized.
It was apparent you had done your homework prior to writing the ticket :slight_smile:

1 Like