1

I'm attempting to follow the nest device access quick start guide, and I'm stuck on the "Get an access token" step here https://developers.google.com/nest/device-access/authorize#get_an_access_token

I'm running the command in a windows terminal exactly as it appears in the guide (except with my client_id, client_secret, and authorization_code):

curl -L -X POST 'https://www.googleapis.com/oauth2/v4/token?
client_id=oauth2-client-id&
client_secret=oauth2-client-secret&
code=authorization-code&
grant_type=authorization_code&
redirect_uri=https://www.google.com'

but it returns this error:

<p><b>411.</b> <ins>That’s an error.</ins>
  <p>POST requests require a <code>Content-length</code> header.

No clue what I'm missing with the header thing. I'm on a Windows 10 machine, in case that matters. I know it did for needing to use double quotes instead of single quotes. Been searching everywhere and haven't been able to find an answer yet. Thanks!

2 Answers2

2

You need to add a Content-Length header for the size of your POST request contents. It's zero in your case I guess. So the following can be added:

curl -L -X POST -H "Content-Length: 0" [...url]
2

If anyone else has had this problem, I was able to get this to work correctly simply by using git bash as my terminal (without having to add the -H "Content-Length: 0" to the command)