Reputation: 1863
I'm building a REST api using express and I want to add authetication to the app. On the client side I have a Angularjs application.
I have this code for the authentication request
app.get('/auth/google', passport.authenticate('google'));
But this code returns a 302 http status, which isn't very helpful in a REST api application. I guess a 401 status code would be more helpful.
I have installed passport-google 0.3
Am I missing something here ?
Upvotes: 1
Views: 1843
Reputation: 51480
I doubt that passport-google
has been intended to be used from REST API.
302
is a redirect status code. passport-google
expects that /auth/google
page has been opened in a browser, so it's redirecting user to google.com authentication dialog.
Try opening it in your browser and what will happen.
I have a feeling that you picked up the wrong tool. Look at passport-localapikey
module, or search for any other REST authentication solution.
I don't think that you'll be able to use passport-google
from pure REST API without hacking it (e.g. monkey-patching its internal parts).
Upvotes: 2