I am doing this request:
POST request to
https://accounts.google.com/o/oauth2/token?
client_secret=xxxxx-x8U-tDOJbCPN3&
grant_type=authorization_code&
redirect_uri=[url]
client_id=xxxxxx-e4u1224f7uqjafv7m1lu2ek5ac01isi4.apps.googleusercontent.com&
code=xxxxxxlpdiZfd_LhYu167gK.QvJZYyoaoQAQ3oEBd8DOtNC9kGrnjwI
So, as doc says, i make that request with these headers:
"Accept-Encoding": "gzip"
"Content-Type": "application/x-www-form-urlencoded"
But when i do it i am getting a 400:
{"error":"invalid_request","error_description":"Required parameter is missing: grant_type"}
I have already solved this. The problem was that i was sending params in query string, and the correct way was sending them as x-www-form-urlencoded. So the correct request had to be like this:
POST /o/oauth2/token? HTTP/1.1
Host: accounts.google.com
Cache-Control: no-cache
Postman-Token: b38df5b3-b64f-338a-1374-220647ee05a0
Content-Type: application/x-www-form-urlencoded
client_secret=xxxxx-x8U-tDOJbCPN3%26&grant_type=authorization_code&redirect_uri=myredirecturi&client_id=xxxxxx-e4u1224f7uqjafv7m1lu2ek5ac01isi4.apps.googleusercontent.com&code=xxxxxxlpdiZfd_LhYu167gK.QvJZYyoaoQAQ3oEBd8DOtNC9kGrnjwI
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With