Saturday, 22 April 2017

Google oauth `redirect_uri_mismatch` error?

I have been able to properly get the code from google server now i am trying to get access token. Here is the code that i have so far

var request = require('request');

module.exports = function (code) {
  console.log(process.env.redirectUri);
  request
    .post("https://www.googleapis.com/oauth2/v4/token",
        {form: {code:code,client_id:process.env.clientId,client_secret:process.env.clientSecret,grant_type:"authorization_code",redirect_uri:process.env.redirectUri}},
        (err,httpResponse,body)=>{
          if(err){
            console.error(err);
          }else{
            console.log(body);
          }
        }
      );
};

The redirect uri is http://localhost:8000/auth/google/token and i have added that to google console as can be seen in image below

dev console screenshot

I am still unable to understand what the problem is. The documentation for the same could be found here.



via georoot

No comments:

Post a Comment