我目前正在尝试允许我的应用程序的用户授权我的应用程序访问他们的 Doubleclick for Advertisers API。我正在使用以下方式处理此授权 Passport.js. 。当我同时包括 简介范围 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"
 }
}

这来自谷歌,这意味着我请求的范围不够。那么任何类型的附加访问都需要配置文件范围吗?为什么我不能只请求 DFA 范围?

有帮助吗?

解决方案

不,Google OAuth 2.0 不需要范围“配置文件”。

如果您只想获得 DFA API 的授权,则只需此范围 https://www.googleapis.com/auth/dfatrafficking(作为 官方文档 说,并且 这个java样本 仅使用此范围)

您收到“权限不足”的原因是当您使用 passport.authenticate 'dfa' 使用 OAuth 提供程序(在您的情况下是 Google)执行身份验证,其中需要范围“配置文件”(如 这个医生说, ,“个人资料”是登录的基本范围)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top