Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Update README.

  • Loading branch information...
commit 01289d0e5caca22c1e9ba4f89ce7535978d1199a 1 parent 3fae687
@jaredhanson authored
Showing with 50 additions and 0 deletions.
  1. +50 −0
@@ -3,6 +3,56 @@
[Passport]( strategy for authenticating
with [Google]( using OpenID 2.0.
+## Installation
+ $ npm install passport-google
+## Usage
+#### Configure Strategy
+The Google authentication strategy authenticates users using a Google account,
+which is also an OpenID 2.0 identifier. The strategy requires a `validate`
+callback, which accepts this identifier and calls `done` providing a user.
+Additionally, options can be supplied to specify a return URL and realm.
+ passport.use(new GoogleStrategy({
+ returnURL: 'http://localhost:3000/auth/google/return',
+ realm: 'http://localhost:3000/'
+ },
+ function(identifier, done) {
Vanuan added a note

seems like a bug. Maybe it's userInfo, identifier, done?

@jaredhanson Owner

It can be identifer, done or identifier, userInfo, done. There's a few other variations as well, depending on what extensions are enabled.

Vanuan added a note

I use only passport-google (openID). A variant with two parameters gives me "object is not a function" error.

When I look to openID strategy:
it seems that this branch is executed: if (arity == 3 || self._profile)

What am I doing wrong? I looked to an example, and I see three parameters there: (identifier, profile, done)

Vanuan added a note

BTW, maybe it's worth to document optional parameters for this function? Like:

function([req], result.claimedIdentifier, [profile], [pape], [oauth], verified)

with additional notes about "_passReqToCallback" and "_profile" options

@jaredhanson Owner

Can you put some console.logs in and print identifer, profile, and done. Do they look like what you expect? I'd recommend filing an issue, which will make it easier to track.

Vanuan added a note

see #16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ User.findByOpenID({ openId: identifier }, function (err, user) {
+ return done(err, user);
+ });
+ }
+ ));
+#### Authenticate Requests
+Use `passport.authenticate()`, specifying the `'google'` strategy, to
+authenticate requests.
+For example, as route middleware in an [Express](
+ app.get('/auth/google',
+ passport.authenticate('google'),
+ function(req, res){
+ // The request will be redirected to Google for authentication, so
+ // this function will not be called.
+ });
+ app.get('/auth/google/callback',
+ passport.authenticate('google', { failureRedirect: '/login' }),
+ function(req, res) {
+ // Successful authentication, redirect home.
+ res.redirect('/');
+ });
+#### Examples
+For a complete, working example, refer to the [signon example](
## Credits
- [Jared Hanson](

0 comments on commit 01289d0

Please sign in to comment.
Something went wrong with that request. Please try again.