gpt4 book ai didi

asp.net - MSAL 3.x GetAuthorizationRequestUrlParameterBuilder 返回错误的数据类型

转载 作者:行者123 更新时间:2023-12-03 04:49:40 26 4
gpt4 key购买 nike

根据ConfidentialClientApplication.GetAuthorizationRequestUrl的引用、方法

Computes the URL of the authorization request letting the user sign-in and consent to the application accessing specific scopes in the user's name. The URL targets the /authorize endpoint of the authority configured in the application.

所以,我应该能够使用如下代码获取授权请求 URL:

string[] graphScopes = { "Files.Read.All", "User.Read" };

ConfidentialClientApplicationBuilder clientBuilder = ConfidentialClientApplicationBuilder.Create(Settings.AzureADClientId);
ConfidentialClientApplication clientApp = (ConfidentialClientApplication)clientBuilder.Build();

var urlBuilder = clientApp.GetAuthorizationRequestUrl(graphScopes);
urlBuilder.WithRedirectUri(loginRedirectUri.ToString());
urlBuilder.WithAuthority(Settings.AzureADAuthority);
var authUrl = await urlBuilder.ExecuteAsync();
authUrl. ????

但是 GetAuthorizationRequestUrlParameterBuilder.ExecuteAsync() 方法返回一个 AuthorizationResult,它不是 URL,并且没有包含 URL 的属性。

有人可以解释我做错了什么,或者解释如何实际获取授权请求 URL?

最佳答案

虽然@TiagoBrenck是正确的,但这是一个错误,我已经记录了https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1193

就编码风格而言,我会编写类似这样的代码:

  string[] graphScopes = { "Files.Read.All", "User.Read" };

IConfidentialClientApplication cca = ConfidentialClientApplicationBuilder.Create("<client_id>").Build();

Uri url = await cca.GetAuthorizationRequestUrl(graphScopes)
.WithRedirectUri("some_uri")
.WithAuthority(AzureCloudInstance.AzurePublic, AadAuthorityAudience.AzureAdAndPersonalMicrosoftAccount)
.ExecuteAsync(CancellationToken.None)
.ConfigureAwait(false);

关于asp.net - MSAL 3.x GetAuthorizationRequestUrlParameterBuilder 返回错误的数据类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56370889/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com