Vla*_*lyk 7 c# authentication azure azure-active-directory azure-management-api
我尝试了3种没有结果的方法:
var context = new AuthenticationContext($"https://login.windows.net/{tenantId}");
var result = context.AcquireToken("https://management.core.windows.net/", clientId, new Uri(redirectUri));Run Code Online (Sandbox Code Playgroud)
,但它失败,但例外:
Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException was unhandled
Message: An unhandled exception of type 'Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException' occurred in Microsoft.IdentityModel.Clients.ActiveDirectory.dll
Additional information: AADSTS90014: The request body must contain the following parameter: 'client_secret or client_assertion'.
Trace ID: aa2d6962-5aea-4f8e-bed4-9e83c7631887
Correlation ID: f7f1a61e-1720-4243-96fa-cff182150931
Run Code Online (Sandbox Code Playgroud)
var context = new AuthenticationContext($"https://login.windows.net/{tenantId}");
var result = context.AcquireToken("https://management.core.windows.net/", new ClientCredential(clientId, clientSecret));Run Code Online (Sandbox Code Playgroud)
其中clientSecret是我的应用程序的秘密应用程序密钥.此版本返回一个令牌,但使用此令牌的请求将返回403 Forbidden:服务器无法验证请求.验证证书是否有效并与此订阅相关联.
var context = new AuthenticationContext(string.Format("https://login.windows.net/{0}", tenantId));
// TODO: Replace with your Azure AD user credentials (i.e. admin@contoso.onmicrosoft.com)
string user = "{YOUR-USERID]";
string pwd = "{YOUR-USER-PASSWORD}";
var userCred = new UserCredential(user, pwd);
AuthenticationResult result =
await context.AcquireTokenAsync("https://management.core.windows.net/", clientId, userCred);Run Code Online (Sandbox Code Playgroud)
但它也失败了与第一种情况相同的例外......
你能帮助我吗?
| 归档时间: |
|
| 查看次数: |
6046 次 |
| 最近记录: |