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.