我可以使用这些参数Get-MsalToken -ClientId '' -TenantId '' -Scopes ''
获取不记名令牌
我正在尝试将其转换为使用C#而不是PowerShell:
var clientId = "xyz";
var tenantId = "xyz";
// We intend to obtain a token for Graph for the following scopes (permissions)
string[] scopes = { $"{clientId}/.default" };
string authority = $"https://login.microsoftonline.com/{tenantId}";
IPublicClientApplication app = PublicClientApplicationBuilder.Create(clientId)
.WithAuthority(new Uri(authority))
.WithRedirectUri("http://localhost")
.Build();
AuthenticationResult result = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
var token = result.AccessToken;
但我得到一个错误说:“请求中指定的重定向URI”http://localhost“与为应用程序配置的重定向URI不匹配”
1条答案
按热度按时间piok6c0g1#
这是因为您在Azure中的应用未配置为重定向到
localhost
。您需要在Azure门户中更新它。参见:https://learn.microsoft.com/en-us/troubleshoot/azure/active-directory/error-code-aadsts50011-redirect-uri-mismatch