我目前正在尝试允许我的应用程序的用户授权我的应用程序访问他们的 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 范围?
最佳答案
不,Google OAuth 2.0 不需要范围“配置文件”。
如果您只想获得 DFA API 的授权,则只需要此范围 https://www.googleapis.com/auth/dfatrafficking
(如 official doc 所说,并且 this java sample 仅使用此范围)
您收到“权限不足”的原因是当您使用 OAuth 提供程序(在您的例子中是 Google)执行 passport.authenticate 'dfa'
身份验证时,其中需要范围“profile”(如 this doc says ,“profile”是登录的基本范围)
关于node.js - Google OAuth2.0 是否需要 "profile"范围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24023757/