OAuth Authentication fails with error AADSTS65005 in ios Xamarin

ぐ巨炮叔叔 提交于 2019-12-08 03:52:55

问题


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?


回答1:


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):



来源:https://stackoverflow.com/questions/41824862/oauth-authentication-fails-with-error-aadsts65005-in-ios-xamarin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!