【问题标题】:Is "profile" scope required for Google OAuth2.0?Google OAuth2.0 是否需要“配置文件”范围?
【发布时间】:2014-07-24 07:06:09
【问题描述】:

我目前正在尝试允许我的应用程序用户授权我的应用程序访问他们的 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"
 }
}

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

【问题讨论】:

    标签: node.js oauth oauth-2.0 google-oauth passport.js


    【解决方案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、“配置文件” " 是登录的基本范围)

    【讨论】:

      猜你喜欢
      • 2013-10-11
      • 2020-05-01
      • 2014-11-12
      • 1970-01-01
      • 2020-04-24
      • 1970-01-01
      • 1970-01-01
      • 2015-06-06
      • 2018-07-19
      相关资源
      最近更新 更多