我正在使用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...。这就是我们所知道的。”
我已经尝试过使用DELETE
或POST
或在Authorize
标头中将令牌作为Bearer令牌而不是查询参数进行传递,但无济于事;响应总是一样。
出了什么问题?
答案 0 :(得分:1)
POST命令可撤销。请尝试使用以下curl命令:
curl -d -X -POST'https://oauth2.googleapis.com/revoke?token=PUT_TOKEN_HERE'--header'内容类型:application / x-www-form-urlencoded'
答案 1 :(得分:0)
由于只有 Google 知道的原因,他们似乎没有发布正确的撤销端点。
我去年一直在使用的那个列在他们的 python 客户端库 tests/data/client_secrets.json 中:“https://accounts.google.com/o/oauth2/revoke”