0
votes

I'm trying to use Google's 'google-api-nodejs-client' package (https://github.com/google/google-api-nodejs-client) to handle OAuth 2.0 authentication.

I've modified the example in examples/oauth2.js to console.log the entire profile object.

What scope can I use to correctly extract users' 'givenName' and 'familyName' if they're authenticating using a Google Apps account? Using the following scope:

scope: [
  'https://www.googleapis.com/auth/plus.login',
  'https://www.googleapis.com/auth/plus.profile.emails.read'
]

returns the following response once authenticated:

{ kind: 'plus#person',
  etag: '"LONG STRING"',
  emails: [ { value: '[email protected]', type: 'account' } ],
  objectType: 'person',
  id: '123456',
  displayName: '',
  name: { familyName: '', givenName: '' },
  image:
   { url: 'https://lh3.googleusercontent.com/ etc etc',
     isDefault: false },
  isPlusUser: false,
  language: 'en_GB',
  circledByCount: 0,
  verified: false,
  domain: 'example.example' }
1

1 Answers

0
votes

I tried fooling around with the API on the API Explorer (https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me) and only needed the 'https://www.googleapis.com/auth/plus.login' scope to get my familyName and givenName.

Perhaps the user that you are requesting the data from does not have a given and family name set?