Unable to redirect user to authentication page. Usually redirect call back url will be called and prompted to user to login and then we capture the token from exchange code.
In my case, the page just hangs there without redirecting. Where did I go wrong?
var OAuth2 = google.auth.OAuth2;
var oauth2Client = new OAuth2(
'74615484392-n6dv3aaaqu49lgaaaaaaa16olvaaabfm.apps.googleusercontent.com',
'client-secret here',
'http://localhost:5027/auth/google/Bloggercallback'
);
app.get('/creatGoogleBloggerPost', function(req, res, next){
console.log('creatGoogleBloggerPost');
var url = oauth2Client.generateAuthUrl({
access_type: 'offline',
scope: 'https://www.googleapis.com/auth/blogger'
});
});
app.get("/auth/google/Bloggercallback", function (req, res, next) {
console.log('callback called +++++++++++++++'); //prints this line
var code;
oauth2Client.getToken(code, function (err, tokens) {
// Now tokens contains an access_token and an optional refresh_token. Save them.
if (!err) {
oauth2Client.setCredentials(tokens);
} else {
console.log('error getting the token' , err);
}
});
});
When I click on the button, a page pops up and supposed to be redirected to google login page but it doesn't redirect
via kittu
No comments:
Post a Comment