0

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: 'example@example.example', 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' }
4

1 回答 1

0

我尝试在 API Explorer ( https://developers.google.com/apis-explorer/#p/plus/v1/plus.people.get?userId=me ) 上玩弄 API,只需要获取'https://www.googleapis.com/auth/plus.login'范围我的familyNamegivenName.

也许您正在向其请求数据的用户没有设置给定的姓氏?

于 2014-07-25T04:57:23.770 回答