I am developing a node application that needs to be authenticated with google. When I request a token, https://accounts.google.com/o/oauth2/token responds:
error: 400 { "error" : "invalid_request" }
I tried to make the same request in curl and got the same error, so I suspect that something is wrong with my request, but I can not understand what. I pasted my code below:
var request = require('request'); var token_request='code='+req['query']['code']+ '&client_id={client id}'+ '&client_secret={client secret}'+ '&redirect_uri=http%3A%2F%2Fmassiveboom.com:3000'+ '&grant_type=authorization_code'; request( { method: 'POST', uri:'https://accounts.google.com/o/oauth2/token', body: token_request }, function (error, response, body) { if(response.statusCode == 201){ console.log('document fetched'); console.log(body); } else { console.log('error: '+ response.statusCode); console.log(body); } });
I checked triple to make sure that all the data I send is correct and I still get the same error. What can I do to debug this further?
source share