HTTP RESTful API Invalid token

Hello Blynkers,
I trying to make bot on python, which send and get information with ESP8266 through Blynk cloud. I use HTTP RESTful API for this, but when I use this:

linkIn = 'http://blynk-cloud.com/{}/get/{}'
request = requests.get(linkIn.format(auth, pin))
print(request.text)

it return “Invalid token.”, In browser it works normally, but on remote server…
What’s wrong?

There are three Blynk cloud servers around the world, and when using the app or the library they do some very clever things to direct the request to the server that contains your project and its associated data.
However, this doesn’t work when using the API, so its necessary to specify the IP address of the server that contains your project.

As the API all is working in the browser of your home PC then it means that normal DNS routing is taking you to the correct server, so from your home PC you need to Ping blynk-cloud.com and us the IP address that’s returned in your API call.

This is mentioned in the documentation:

HTTP RESTful API

Blynk HTTP RESTful API allows to easily read and write values of Pins in Blynk apps and Hardware.
API description can be found here. Warning : Blynk HTTP API still has GEO DNS issue. This means, for now you need to use direct server IP instead of hostname in order to make it work with 3-d party services like IFTTT.

https://docs.blynk.cc/#http-restful-api

Pete.

I changed code:

linkIn = '139.59.206.133:80/{}/get/{}'
request = requests.get(linkOut.format(BLYNK_AUTH, pin, password))

But now I get this error:
No connection adapters were found for ‘139.59.206.133:80/cUHbXXXXXXXXXXXXXXXXXXXXXXXLsQc/update/V1?value=qwerty’

I think that if you’re going to specify a port then it needs to be 8080

Pete.

I checked port 8080 too, but I got this error.

And what if you don’t specify a port?

Pete.

Thank you! Thats working and I forgot ‘http://’

1 Like

Hi Pete,

I am facing the same issue.

Using Postman to test my API requests

When I make a GET request to get the pin value of V0 or V1, I receive the message as Invalid Token.

My request look like this-

 GET http://188.166.206.43/{auth token}/get/V1`

Response: Invalid Token

In addition to this, I also tried adding port numbers 80 and 8080. Still no luck!

Please help me out here.

@vcr3at3 please create a new " need help with my project " topic and provide more details like blynk IOT or legacy, library version etc.

1 Like