Skip to content

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredhanson committed Nov 4, 2011
1 parent 3fae687 commit 01289d0
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Expand Up @@ -3,6 +3,56 @@
[Passport](https://github.com/jaredhanson/passport) strategy for authenticating
with [Google](http://www.google.com/) 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) {

This comment has been minimized.

Copy link
@Vanuan

Vanuan Apr 10, 2013

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

This comment has been minimized.

Copy link
@jaredhanson

jaredhanson Apr 10, 2013

Author Owner

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

This comment has been minimized.

Copy link
@Vanuan

Vanuan Apr 10, 2013

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: https://github.com/jaredhanson/passport-openid/blob/master/lib/passport-openid/strategy.js#L200
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)

This comment has been minimized.

Copy link
@Vanuan

Vanuan Apr 10, 2013

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

This comment has been minimized.

Copy link
@jaredhanson

jaredhanson Apr 10, 2013

Author 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.

This comment has been minimized.

Copy link
@Vanuan

Vanuan Apr 10, 2013

see #16

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](http://expressjs.com/)
application:

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](https://github.com/jaredhanson/passport-google/tree/master/examples/signon).

## Credits

- [Jared Hanson](http://github.com/jaredhanson)
Expand Down

0 comments on commit 01289d0

Please sign in to comment.