NEST API C# Unauthorized Error

auth

#1

Hi,
I was recently playing with sending API Request to Nest Thermostat via Postman and everything works fine, but when i’m sending same request via c# code :

https://pastebin.com/YcfcrcB9

and i’m gettting this error

{“error”:“unauthorized”,“type”:“https://developer.nest.com/documentation/cloud/error-messages#auth-error",“message”:“unauthorized”,“instance”:"7f97abd6-4aa6-40db-840f-88d079de9d73”}

What am i doing wrong ?


#2

Are you attempting to reuse the auth code more than once?
See "Key Point: Your authorization code is valid for one POST call."
at https://developers.nest.com/documentation/cloud/how-to-auth

Note that an auth code is different from an access token.
The former can be used once.
The latter can be used multiple times.

Also - need to handle redirects correctly. See https://developers.nest.com/documentation/cloud/how-to-handle-redirects

Hope these help