【问题标题】:Issue with grant for OAuth2 authentication with google与谷歌进行 OAuth2 身份验证的授权问题
【发布时间】:2015-07-20 05:43:00
【问题描述】:

我正在使用Grant 与 google 进行 OAuth2 身份验证。我在 config.json 中提供了所有参数:

  {
    "server": {
    "protocol": "https",
    "host": "thooslo-com-shaunakde.c9.io"
  },
  "google":{
    "authorize_url": "https://accounts.google.com/o/oauth2/auth",
    "access_url": "https://accounts.google.com/o/oauth2/token",
    "oauth": 2,
    "custom_parameters": ["access_type"],
    "scope_delimiter":" ",
    "scope":["https://www.googleapis.com/auth/youtube","https://www.googleapis.com/auth/drive"],
    "client_id":"39109025743-veaeooi4v9ooirabeseujn8u2ohjbqf7.apps.googleusercontent.com",
    "client_secret":"DO8ozwoFqtP654jzi-wPQF10",
    "callback": "/users"
  }
  }

但它仍然拒绝发送所有参数。我收到“client_id”未发送错误。

我修改了库以打印出 URL,确实是这样:

Starting child process with 'node ./bin/www'
https://accounts.google.com/o/oauth2/auth?response_type=code&redirect_uri=https%3A%2F%2Fthooslo-com-shaunakde.c9.io%2Fconnect%2Fgoogle%2Fcallback&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive
GET /connect/google 302 26.492 ms - 574

通过某种排列,我确实设法使第一步工作了一次,但随后由于找不到 client_secret 而失败。

我做错了什么吗?该库似乎没有错误。

【问题讨论】:

标签: javascript node.js oauth-2.0 grant-oauth


【解决方案1】:

有这个配置就够了

{
    "server": {
    "protocol": "https",
    "host": "thooslo-com-shaunakde.c9.io"
  },
  "google":{
    "key":"39109025743-veaeooi4v9ooirabeseujn8u2ohjbqf7.apps.googleusercontent.com",
    "secret":"DO8ozwoFqtP654jzi-wPQF10",
    "scope":[
      "https://www.googleapis.com/auth/youtube",
      "https://www.googleapis.com/auth/drive"
    ],
    "callback": "/users"
  }
}

【讨论】:

    猜你喜欢
    • 2018-07-14
    • 2018-01-01
    • 2015-05-12
    • 2011-09-27
    • 2023-01-26
    • 1970-01-01
    • 1970-01-01
    • 2016-02-15
    相关资源
    最近更新 更多