I am looking to initiate an oauth request in a new window for my project.
Here is how I can open the new window:
var authWindow = $window.open("/auth/google/signin", "");
After the callback, my server will respond with JSON data:
app.get('/auth/google/signin',
passport.authenticate('google', { scope: 'https://www.googleapis.com/auth/plus.login'}),
function(req, res, next) {
// The request will be redirected to Google for authentication, so this
// function will not be called.
}
);
app.get('/auth/google/callback',
function(req, res, next) {
passport.authenticate('google', function(err, user, info) {
console.log('google authenticate callback');
// Handle the response, then send token and user...
res.json({
token:token,
user: user
});
})(req, res, next);
}
);
I need to know how to wait for the redirect to /auth/google/callback and receive the JSON response from the server.
What would be the best approach to handle this waiting period and managing the JSON data? Should I use a callback or postMessage()?