gpt4 book ai didi

azure - AADSTS50001 : Getting exception while trying to access token from Azure AD by using ADAL from Console client

转载 作者:行者123 更新时间:2023-12-04 08:49:05 24 4
gpt4 key购买 nike

尝试从控制台客户端使用 ADAL 访问 Azure AD token 时出现异常。

步骤:

  1. 我已使用我的 Web API 应用程序 localhost:44307 配置了 Azure AD。
  2. 添加了客户端 ID、客户端 key 所需的配置。
  3. 通过更改此链接中建议的 list 来解决此问题。 https://www.google.com/search?q=AADSTS50001+%2B+azure+AD+athentication&oq=AADSTS50001+%2B+azure+AD+athentication&aqs=chrome..69i57.10202j0j7&sourceid=chrome&espv=210&es_sm=93&ie=UTF-8#q=AADSTS50001&safe=active

ADAL 版本使用: Microsoft.IdentityModel.Clients.ActiveDirectory 2.6.0-alpha

控制台应用程序代码:

void GetToken()
{
clientId = "be6b055a-4efc-222a-2187-49657e6f4f1b";
string ClientKey = "c/uIMlsqn9SzJLKKyBle42Ym+tgcaC2tbMlWxJQawE";
string ClientCredential clientCred = new ClientCredential(clientId, ClientKey);

authenticationContext = new AuthenticationContext("https://login.windows.net/MyDevAD.onmicrosoft.com");
authenticationResult = authenticationContext.AcquireToken("https://mylocalwebapiapp.com/", clientCred);
....
}
<小时/>

Fiddler 输入:

POST https: //login.windows.net/MyDevAD.onmicrosoft.com/oauth2/token HTTP/1.1
Content-Type: application/x-www-form-urlencoded
client-request-id: 53262b17-1234-4ed9-bdb3-748d332eb44b
return-client-request-id: true
x-client-SKU: .NET
x-client-Ver: 2.6.0.0
x-client-CPU: x64
x-client-OS: Microsoft Windows NT 6.3.9600.0
Host: login.windows.net
Content-Length: 185
Expect: 100-continue
Connection: Keep-Alive

grant_type=client_credentials&resource=https%3A%2F%2Flocalhost%3A44307%2F&client_id=be6b055a-4efc-408a-8187-42137e6f4f1b&client_secret=c%2FuIMlsqn9SzJLKKyBle123Ym%2BtgcaC3tbMlWxJQawE%3D
<小时/>

Fiddler 输出:

HTTP/1.1 400 Bad Request
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Set-Cookie: x-ms-gateway-slice=ProductionB; path=/
x-ms-request-id: e89741b2-570d-44f6-9e71-6533b083abcd
client-request-id: 35262b17-4771-4ed9-bdb3-748d332eb33b
X-Content-Type-Options: nosniff
X-Powered-By: ARR/3.0
X-Powered-By: ASP.NET
Date: Tue, 01 Apr 2014 19:05:51 GMT
Content-Length: 438

{"error":"invalid_resource","error_description":"AADSTS50001: Resource 'https://mylocalwebapiapp.com/' is not registered for the account.\r\nTrace ID: e89741b2-570d-44f6-9e71-6533b083cdad\r\nCorrelation ID: 35262b17-4771-4ed9-cddb3-748d332eb44b\r\nTimestamp: 2014-04-01 19:05:53Z","error_codes":[50001],"timestamp":"2014-04-01 19:05:53Z","trace_id":"e89741b2-570d-44f6-9e71-6533b083cdad","correlation_id":"35262b17-4771-4ed9-bdb3-748d332eb44b"}
<小时/>

注意:发布的 URL 和 ID 是伪造的。

最佳答案

我们不应该引入任何改变。我建议仔细检查您是否为客户端应用程序分配了访问 Web API 的正确权限。请注意,您的应用程序正在获取具有其自己的凭据的 token ,因此您需要直接分配应用程序权限(而不是委派权限)。华泰五、

关于azure - AADSTS50001 : Getting exception while trying to access token from Azure AD by using ADAL from Console client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22795169/

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