0

I am intending to POST Nest API to get the access token with ESP8266 or Arduino. I read carefully https://developers.nest.com/guides/api/how-to-auth#test_for_csrf_attacks and Calling nest api with esp8266 using arduinoEDK

I tried to POST api.home.nest.com wth with URL:/oauth2/access_token but don't know what port to: I tried 80, 9553 and 443 with no success.

1 Answer 1

0

Nest runs its API over HTTPS, which uses port 443. Even if they allowed port 80 you should not use that; you'd be transmitting your credentials or API token unencrypted, which is dangerous.

If your code is running on an ESP8266 be sure to use an SSL library. It's not enough to just speak the HTTP protocol to port 443.

You didn't share any code so I can't advise further, but consider using the BearSSL::WiFiClientSecure class for your connection.

There's a good example of this at

https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266HTTPClient/examples/BasicHttpsClient/BasicHttpsClient.ino

You'll need to know the SSL fingerprint for the Nest server. You can find this by running

openssl s_client -connect api.home.nest.com:443 < /dev/null 2>/dev/null | openssl x509 -fingerprint -noout | cut -d'=' -f2

in a terminal window on a Mac or Linux computer. The fingerprint allows your client to confirm that the server is who it claims to be.

As I write this, the fingerprint is currently:

DE:AA:EB:EE:C0:4B:14:97:27:C8:29:46:5C:05:44:2C:26:DE:55:6B

Be aware that this can change with time (or even depending on the specific server which handles your request), so you may need to change it. You can find the line that calls client->setFingerprint() in the example at the link above; that's where you'd use server fingerprint.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.