Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mwbrooks committed Feb 14, 2019
1 parent e561c22 commit 72af221
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ application:
app.get('/auth/google',
passport.authenticate('google', { scope: 'https://www.google.com/m8/feeds' }));

app.get('/auth/google/callback',
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
Expand Down Expand Up @@ -97,13 +97,33 @@ application:
app.get('/auth/google',
passport.authenticate('google'));

app.get('/auth/google/callback',
app.get('/auth/google/callback',
passport.authenticate('google', { failureRedirect: '/login' }),
function(req, res) {
// Successful authentication, redirect home.
res.redirect('/');
});
```
#### Google Plus API Deprecation

The default for `passport-google-oauth2` is to use the Google+ People API to
get the profile information for the user signing in. With this API being
removed in early 2019 you should look towards using the OAuth 2 User Info
endpoint instead. You can switch to this endpoint using this configuration
option.

```javascript
new GoogleStrategy({
clientID: GOOGLE_CLIENT_ID,
clientSecret: GOOGLE_CLIENT_SECRET,
callbackURL: "http://www.example.com/auth/google/callback",
// This option tells the strategy to use the userinfo endpoint instead
userProfileURL: "https://www.googleapis.com/oauth2/v3/userinfo",
}
```
The structure of the `profile` object will be the same but you may get
less profile information than you did before.
## Examples
Expand Down
4 changes: 2 additions & 2 deletions lib/passport-google-oauth/profile/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ exports.parse = function(json) {
}

var profile = {};
profile.id = json.sub;
profile.id = json.sub || json.id;
profile.displayName = json.name;
if (json.family_name || json.given_name) {
profile.name = { familyName: json.family_name,
givenName: json.given_name };
}
if (json.email) {
profile.emails = [ { value: json.email, verified: json.email_verified } ];
profile.emails = [ { value: json.email, verified: json.email_verified || json.verified_email } ];
}
if (json.picture) {
profile.photos = [{ value: json.picture }];
Expand Down

0 comments on commit 72af221

Please sign in to comment.