c# - WSO2 身份服务器 5.7.0 撤销方法不起作用
问题描述
WSO2 Identity Server 5.7.0 撤销方法不起作用,导致错误代码:401 -> UnAuthorize。
此链接说明如何使用 revoke 方法,我想将其用于 c# 代码:
WebRequest request2 = WebRequest.Create("https://localhost:9443/oauth2/revoke?token=" + accessToken + "&token_type_hint=access_token");
request2.Method = "POST";
request2.PreAuthenticate = true;
request2.Credentials = CredentialCache.DefaultCredentials;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
request2.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request2.Headers.Add("Authorization", "Basic " + "YFnfIeUVkpW64sSysLgoqajioOIa" + ":" + "L7rtcwWDqAQ6NdsvY2ZqUTAi5wMa");
var response2 = request2.GetResponseAsync();
response2.Wait();
var t = response2.Result;
解决方案
您必须对授权标头中的 <client id>:<client secret> 值进行基本 64 编码。标题应该看起来像,
Authorization: Basic WUZuZkllVVZrcFc2NHNTeXNMZ29xYWppb09JYTogTDdydGN3V0RxQVE2TmRzdlkyWnFVVEFpNXdNYQ==
如果您在文档中尝试 curl 命令,--basic -u "<client id>:<client secret>"
部分将执行相同的操作,如果您-v
在命令中添加选项,您可以看到 curl 请求发送的实际标头值。
推荐阅读
- python - 通过 MPI [MPI4py] 发送复数时的 MPI_ERR_TRUNCATE
- r - 类数组 | 如何转换为数据框
- kotlin - 请解释物业代表
- java - 在用java编写的破砖游戏中,如果它同时击中两块砖,我应该如何防止速度反转两次?
- html - addEventListener 到 HTMLDivElement 数组
- python - 如何在 Holoviews 中显示围绕 GridSpace/GridMatrix 的内轴?
- php - PHP中的重复函数
- ruby-on-rails - 将链接放入 Rails 中的验证消息中
- vba - 设置标题列的名称 - 预期 14 个列名称
- python - PyTest 测试什么时候应该是类的一部分,什么时候应该是独立的方法?