OAuth 2.0 Google Apps 用户名的范围与 google-api-nodejs-client



我正在尝试使用谷歌的' Google -api-nodejs-client'包(https://github.com/google/google-api-nodejs-client)来处理OAuth 2.0认证。

我已经修改了examples/oauth2.js中的示例,以console.log整个配置文件对象。

我可以使用什么范围来正确提取用户的'给定名称'和'家庭名称',如果他们使用谷歌应用程序帐户进行身份验证?使用以下作用域:

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

通过身份验证后返回以下响应:

{ 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' }

我试着在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

也许您请求数据的用户没有给定和姓氏集?

最新更新