BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

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.

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