[SOLVED] 403 - "Authentication credentials were not provided." -- But they were (CURL)

I am trying to get a Spark core to post data to ubidots, but am not seeing any data show up in ubidots. Trying to simplify the troubleshooting - I’ve tried to access the ubidots API via some basic curl commands. When I do this, i get 403 - "“Authentication credentials were not provided.” but they are right there in the request headers! I’ve generated a token, and used that in X-Auth-Token request header. Not sure what I’m doing wrong here - suspect it’s painfully obvious!

Request:

HTTP GET things.ubidots.com/api/v1.6/datasources/
Accept: */*
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8
Content-Type: application/json
X-Auth-Token: ei...redacted-for-community-post...1d

Response:

403
{
    "detail": "Authentication credentials were not provided."
}

Hi @egraham05,

Please check that you are using a Ubidots Token and not your API Key. You can see this in your profile tab --> “API Keys”. Here’s a curl GET command that just worked for me:

curl -X GET -H "Content-type: application/json" -H "X-Auth-Token: 7lbgBbfGh5xxxj1ucunhfnYrMPLJh1" things.ubidots.com/api/v1.6/datasources

Thanks for the quick answer. I am using a token. I generated one just for troubleshooting this via community, and I get the same response!

community-token	eiJEJ4OwjdPYBJBu2UExhSi40yr21d

Trying a curl with that token:

curl -X GET -H "Content-type: application/json" -H "X-Auth-Token: eiJEJ4OwjdPYBJBu2UExhSi40yr21d" things.ubidots.com/api/v1.6/datasources

{"detail": "Authentication credentials were not provided."}

If I copy/paste your curl I get the same 403 response:

curl -X GET -H "Content-type: application/json" -H "X-Auth-Token: 7lbgBbfGh5xxxj1ucunhfnYrMPLJh1" things.ubidots.com/api/v1.6/datasources

{"detail": "Authentication credentials were not provided."}

Which makes me think this is somehow tied to my machine…?!

I tried your command but it doesn’t work either. Is this token still created or did you erase it?

Mine had some characters tweaked for security, so here’s a working and temporary one:

curl -X GET -H "Content-type: application/json" -H "X-Auth-Token: 7lIgBfuGWCh56j1ucunhfnYrMPLJh1" things.ubidots.com/api/v1.6/datasources

A good alternative to curl is Postman, I always use it for API testing: Postman Chrome Extension.

I tried your command and got a valid response - so issue is not my machine.

Good suggestion on Postman, thanks for the tip.

Regenerated both short and long token via the web UI (the one from prior post is still active) and received the same error message for each. Then decided to back-up a few steps and try to request a token over API

{
    "error": "Your apikey is not valid, please contact the administrator"
}

So this gets weird… I then log out of ubidots, log back in via a different browser (Chrome not Safari), navigate to my API Keys, and all of the tokens are gone and my key is different.

Using the new key, I try calling over API to generate a token. Receive:

{
    "error": "Your apikey is not valid, please contact the administrator"
}

I then created a new short token via the UI, try the call to list data sources via Postman, and receive the expected response.

{
    "count": 0,
    "next": null,
    "previous": null,
    "results": []
}

Great that it’s working - wonder if it’s Postman or curl, try curl:

curl -X GET -H "Content-type: application/json" -H "X-Auth-Token: Fq534NgS...edit...U5ayL02KvN" things.ubidots.com/api/v1.6/datasources

{"count": 0, "next": null, "previous": null, "results": []}

Not sure what was going on there, but it’s working now. I appreciate the help troubleshooting, thanks!

Hello @egraham05,

Thanks for your feedback. We were able to detect that a small portion of the users had been directed to our test environment (app.draft.ubidots…) instead of the production one (app.ubidots…) . We are looking into the cause, which might be an external link that missguided some users including yourself. This is why you were getting tokens in one account (the draft one) and not being able to post data with them to things.ubidots.com.

Glad it’s solved now for you.

Best,

  • Agustín

By the way, if you’d already have a lot of data in the draft account and would like to move it to the new account, we’ll glad to do it for you. Just let us know.

Thanks @aguspg!

No worries on moving the data, there was nothing there.

I am now up an running, the spark core is successfully posting data, thanks again for the help.

1 Like

Excellent! Btw here some sample projects: http://blog.ubidots.com/topic/spark-core

Hi,
I cannot get my Particle Photon to send data to Ubidots. I am using the sample project from Ubidots that reads a photocell. I added the HTTPclient library to the code (per instructions), but get several error messages. For one, it says my “variable is empty”. I am using the proper Ubidots Token and not my API Key. When I check variable details it simply says:
“detail”: “Authentication credentials were not provided.”
Why is the server denying my request to send data to Ubidots? What should I check to find out where the problem is?
Thanks,

Holy old thread, Batman!

However, I am seeing the same issue. I have tried Ubidots on multiple Particle Photons and the problem persists on all of them. I would also add that I tried uncommenting the DNS lines and the I get a build error on the library and so that seems broken too.

Yes :slight_smile: Old thread indeed. Interesting what you report. Is there another free service, like Ubidots, that might work with the Particle Photon? If you can log into the Particle community, here is a recent smattering of posting that are trying to understand this issue.

Interesting, I have gotten past the 403 error, but I still do not see any data. Something seems to be broken. In this case, I am using a dedicated Photon and only the code provided.

@1eb13 @JL_678 this question was solved and explained here: https://community.particle.io/t/ubidots-and-the-particle-photon/17933/11?u=aguspg

@joe486 - Thank you for the link. I have made the changes to the code and will test it out tonight. (I do not have access to the Photon right now.)

On a side note, if this is the correct code then someone at Ubidots should update the tutorial to reflect this. It is frustration for new Ubidotters to follow a tutorial only to find that it is incorrect!

1 Like

Thanks @JL_678 @joe486. The old tutorial is alright and still works with our Spark. However this new code for the Photon is working too, so we will add it as a separate section for the Photon.

Este topic está ahora cerrado. No se admiten nuevas respuestas