jaredhanson / passport-google

Google (OpenID) authentication strategy for Passport and Node.js.
MIT License
149 stars 80 forks source link

An example in README doesn't work. Callback should be documented more #16

Open Vanuan opened 11 years ago

Vanuan commented 11 years ago

I tried an example described in README:

    function (identifier, done) {
        console.log(identifier);
        console.log(done);
        done(null, {id: identifier});
    }

And I've got:

https://www.google.com/accounts/o8/id?id=ID
{ displayName: 'Name Surname',
  emails: [ { value: 'mail@gmail.com' } ],
  name: { familyName: 'Surname', givenName: 'Name' } }

            done(null, {id: identifier});
            ^
TypeError: object is not a function

Note, that when I add an additional parameter, it works as expected:

    function (identifier, profile, done) {
        console.log(identifier);
        console.log(profile);
        console.log(done);
        done(null, profile);
    }
https://www.google.com/accounts/o8/id?id=ID
{ displayName: 'Name Surname',
  emails: [ { value: 'mail@gmail.com' } ],
  name: { familyName: 'Surname', givenName: 'Name' } }
[Function: verified]
jaredhanson commented 11 years ago

Thanks! I will investigate.

Vanuan commented 11 years ago

I debugged a little. And it seems that GoogleStrategy always sets options.profile, so that this branch with 3 parameters is always executed, even if a number of the parameters is less than 3.