node.js - Google OAuth2.0 是否需要 "profile"范围?

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

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

相关文章:

javascript - libxmljs 的替代品

javascript - NEDB 查询在数组上使用 $nin 返回误报

node.js - 无法执行存储过程: 'One of the specified inputs is invalid.'

php - 谷歌登录oauth2每次都重新询问访问权限

php - YouTube Oauth2 token 问题

java - 如何使用 OAUTH2 从 Java 访问 Outlook.office365.com IMAP?

node.js - Mongoose 在聚合用户中找到除一个之外的所有用户

javascript - Oauth 服务器在成功或错误时重定向,使用 HTTP 重定向还是 Javascript?

ruby-on-rails - Google oauth via devise 和 omniauth/oauth 不断请求访问

javascript - 来自 GoogleAPI 的 JWT 的 Oauth2 token 响应 "invalid_grant"