Google OAuth2.0需要“个人资料”范围吗?

我目前正在尝试允许我的应用程序的用户授权我的应用程序访问他们的Doubleclick for Advertisers API。 我使用Passport.js来处理这个授权。 当我包含这样的configuration文件作用域和DFA作用域时:

app.get '/requestAccess', passport.authenticate 'dfa', scope: [ 'https://www.googleapis.com/auth/dfatrafficking', 'profile' ] 

这工作正常。 不过,我只关心DFA api,而实际上我并不打算使用configuration文件范围中的任何内容,所以我想删除它:

  app.get '/requestAccess', passport.authenticate 'dfa', scope: [ 'https://www.googleapis.com/auth/dfatrafficking', ] 

当我现在批准使用这条路线时,我得到:

  "error": { "errors": [ { "domain": "global", "reason": "insufficientPermissions", "message": "Insufficient Permission" } ], "code": 403, "message": "Insufficient Permission" } } 

这来自Google,这意味着我要求的范围是不够的。 是否需要configuration文件范围才能进行任何其他访问? 为什么我不能只请求DFA范围?

不,Google OAuth 2.0不需要范围“个人资料”。

如果您只想获得DFA API的授权,则只需要https://www.googleapis.com/auth/dfatrafficking (如官方文档所述 , 此java样本仅使用此范围)

您获得“权限不足”的原因是您使用passport.authenticate 'dfa'使用OAuth提供程序(在这种情况下,它是谷歌)的passport.authenticate 'dfa'身份validation执行,其中范围“configuration文件”是必需的(如本文档所述 ,“configuration文件“是login的基本范围)