OAuth身份验证失败,并在iOS Xamarin中显示错误AADSTS65005 [英] OAuth Authentication fails with error AADSTS65005 in ios Xamarin
问题描述
该身份验证曾经对我们有用,但是突然停止了。
我们有一个内置于 Xamamin iOs
的应用程序,并且已在Azure AD帐户中注册了该应用程序,并提供了 ClientID
,然后按指定的方向重定向URL。但是,当调用 authContext.AcquireToken
异常时,将引发错误:Microsoft.IdentityModel.Clients .ActiveDirectory.AdalServiceException:AADSTS65005:客户端应用程序已请求访问资源 example.com/。此请求失败,因为客户端未在其requiredResourceAccess列表中指定此资源。
跟踪ID:ea22c27c-9913-4423-92dc-6fff1cf9904d
相关ID:4c19258b-2391-4585-911e-853157dde073
时间戳记:2017-01-24 09:28:49Z
我们用于获取令牌的代码:
var authContext = new AuthenticationContext(authority);
if(authContext.TokenCache.ReadItems()。Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems()。First()。Authority);
var authResult =等待authContext.AcquireTokenAsync(resource,clientId,new Uri(returnUri),
new PlatformParameters(UIApplication.SharedApplication.KeyWindow.RootViewController));
对于权限变量,我们使用
The authentication used to work for us earlier but has stopped suddenly.
We have an app built in Xamamin iOs
and have registered the application in Azure AD account, provided the ClientID
and redirect URL as specified. But it throws an error when "authContext.AcquireToken" is being called
Exception: Microsoft.IdentityModel.Clients.ActiveDirectory.AdalServiceException: AADSTS65005: The client application has requested access to resource 'example.com/'. This request has failed because the client has not specified this resource in its requiredResourceAccess list.
Trace ID: ea22c27c-9913-4423-92dc-6fff1cf9904d
Correlation ID: 4c19258b-2391-4585-911e-853157dde073
Timestamp: 2017-01-24 09:28:49Z
Code we are using to acquire token:
var authContext = new AuthenticationContext(authority);
if (authContext.TokenCache.ReadItems().Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
var authResult = await authContext.AcquireTokenAsync(resource, clientId, new Uri(returnUri),
new PlatformParameters(UIApplication.SharedApplication.KeyWindow.RootViewController));
And for authority variable, we are using "https://login.microsoftonline.com/common" to authenticate. We also tried "https://login.windows.net/common" but with no luck.
Has there been any microsoft updates lately which could have stopped this code from running?
Based on the error message, you were trying to access the resource example.com/
.
However this resource was removed to grant to that app.
To fix this issue, you can login the Azure portal to grant this resource to your app again like figure below(switch your Azure AD->App registrations->You App->Settings->Required permissions->Add):
这篇关于OAuth身份验证失败,并在iOS Xamarin中显示错误AADSTS65005的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!