我目前正在尝试允许我的应用程序用户授权我的应用访问他们的Doubleclick for Advertisers API。我正在使用Passport.js处理此授权。当我同时包含profile scope和DFA范围时:
app.get '/requestAccess', passport.authenticate 'dfa',
scope: [
'https://www.googleapis.com/auth/dfatrafficking',
'profile'
]
这很好用。但是,我只关心DFA api,我实际上并不打算使用配置文件范围内的任何内容,所以我想删除它:
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,这意味着我要求的范围不足。是否需要配置文件范围用于任何类型的附加访问?为什么我不能只请求DFA范围?
答案 0 :(得分:1)
不,范围"简介" Google OAuth 2.0不需要。
如果您只想获得DFA API的授权,则只需要此范围https://www.googleapis.com/auth/dfatrafficking
(如official doc所述,this java sample仅使用此范围)
你获得"许可不足的原因"当您使用OAuth提供程序(在您的情况下,它是Google)执行passport.authenticate 'dfa'
身份验证时,范围"配置文件"是必需的(如this doc says,"个人资料"是登录的基本范围)