【问题标题】:Getting 404 when trying to revoke access token from Google OAuth2 revoke endpoint尝试从 Google OAuth2 撤消端点撤消访问令牌时出现 404
【发布时间】:2020-05-03 15:49:48
【问题描述】:

我正在使用 angularx-social-login 向 Google 验证用户。

令牌是这样检索的:

https://accounts.google.com/o/oauth2/iframerpc?action=issueToken&response_type=token%20id_token&login_hint=LOGIN_HINT&client_id=CLIENT_ID&origin=http%3A%2F%2Flocalhost%3A4200&scope=openid%20profile%20email&ss_domain=http%3A%2F%2Flocalhost%3A4200

响应为 JSON 对象,访问令牌为 responseData.access_token

对于吊销,我首先下载https://accounts.google.com/.well-known/openid-configuration,找到吊销端点为https://oauth2.googleapis.com/revoke?token=TOKEN,然后跟随https://developers.google.com/identity/protocols/OAuth2WebServer#tokenrevoke(在示例框中选择选项卡HTTP/REST)我发送请求:

curl -D- -H "Content-type:application/x-www-form-urlencoded" "https://oauth2.googleapis.com/revoke?token=TOKEN"

但我得到的不是成功的响应:

HTTP/1.1 404 Not Found
Date: Thu, 16 Jan 2020 18:07:59 GMT
Content-Type: text/html; charset=UTF-8
Server: ESF
Content-Length: 1710
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
Alt-Svc: quic=":443"; ma=2592000; v="46,43",h3-Q050=":443"; ma=2592000,h3-Q049=":443";    ma=2592000,h3-Q048=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000

响应的正文包含类似“在此服务器上找不到请求的 URL ...。这就是我们所知道的一切。”

我已经尝试过使用DELETEPOST 或将Authorize 标头中的令牌作为承载令牌而不是查询参数传递,但无济于事;响应总是一样的。

出了什么问题?

【问题讨论】:

    标签: angular oauth-2.0 google-api google-oauth


    【解决方案1】:

    POST 命令用于撤销。请尝试使用以下 curl 命令:

    curl -d -X -POST 'https://oauth2.googleapis.com/revoke?token=PUT_TOKEN_HERE' --header 'Content-Type: application/x-www-form-urlencoded'

    【讨论】:

    • 请使用我分享的 curl 命令尝试一次。我是在测试后才发布的。或分享您使用的确切 curl POST 命令。谢谢。
    【解决方案2】:

    由于只有 Google 知道的原因,他们似乎没有发布正确的撤销端点。

    我去年一直在使用的那个列在他们的 python 客户端库 tests/data/client_secrets.json: "https://accounts.google.com/o/oauth2/revoke"

    【讨论】:

      猜你喜欢
      • 2019-02-07
      • 1970-01-01
      • 1970-01-01
      • 2021-12-27
      • 2021-09-11
      • 1970-01-01
      • 2014-08-26
      • 1970-01-01
      • 2019-04-12
      相关资源
      最近更新 更多