Getting Authorization Code 16

Hello, I just got my Tidbyt! I am trying to use the API to access the device. I am getting
code 16, bad authorization string and empty details…

I tried the Tidbyt page, and Python. Here is my Python with the auth strings mangled for
my security, my code uses the whole string, as copied from my phone app, of course.

import http.client

conn = http.client.HTTPSConnection(“api.tidbyt.com”)

headers = {
‘Content-Type’: “application/json”,
‘Authorization’: “XYZyJh…R30QZZZZZZ”
}

conn.request(“GET”, “/v0/devices/intrep-some-other-words-fa”, headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode(“utf-8”))

Anything obviously wrong? Do I need additional set-up on Tidbyt side to use the API?

Here is the response:

{“code”:16, “message”:“auth error: rpc error: code = Unauthenticated desc = Bad authorization string”, “details”:[]}

Thank you all,

-Scott

Your auth header needs to to be prefixed with “Bearer” like this:

headers = {
“Content-Type”: “application/json”,
“Authorization”: “Bearer XYZyJh…R30QZZZZZZ”
}

4 Likes

Awesome! Thank you very much!

Happy Holidays!

-Scott