【发布时间】:2021-06-16 23:24:37
【问题描述】:
我正在以编程方式尝试检索发布此 URL 时返回的授权代码。
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=<client_id>&response_type=code&redirect_uri=https://xyzzy.portal.azure-api.net/docs/services/oauth-server-1/console/oauth2/authorizationcode/callback&response_mode=query&scope=api://qwerty/API.Read&state=12345
当我在邮递员中测试这个时,我有两个步骤。生成那个 URL 的那个,然后我在浏览器中发布一个帖子,我在 URL 地址中得到一个 response_type=somelongcodehere。 在 C# 中,我认为我可以做一些简单的事情
var c2 = new RestClient(ResponseUri); //where ResponseUri is the URL address
c2.Timeout = -1;
var r2 = new RestRequest(Method.POST);
IRestResponse v2 = c2.Execute(r2);
并且在响应中的某处我应该能够看到“代码”,然后能够继续。
我知道这不应该这么困难,而且我错过了一些非常明显的东西。 任何帮助将不胜感激。
谢谢,
【问题讨论】: