使用访问令牌和 MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory 的 LoginAsync

问题描述 投票:0回答:2

我收到“您无权查看此目录或页面”。当我尝试使用访问令牌和

LoginAsync
时出错。这适用于
MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory
的等效形式。我不知道为什么这不起作用。我缺少什么配置吗?

MobileServiceAuthenticationProvider.MicrosoftAccount


azure-active-directory azure-web-app-service azure-mobile-services
2个回答
0
投票
var msaProvider = await WebAuthenticationCoreManager.FindAccountProviderAsync( "https://login.microsoft.com", "https://login.microsoftonline.com/3dd13bb9-5d0d-dd2e-9d1e-7a966131bf85"); string clientId = "6d15468d-9dbe-4270-8d06-a540dab3252f"; WebTokenRequest request1 = new WebTokenRequest(msaProvider, "User.Read", clientId); request1.Properties.Add("resource", "https://graph.microsoft.com"); WebTokenRequestResult result = await WebAuthenticationCoreManager.RequestTokenAsync(request1); if (result.ResponseStatus == WebTokenRequestStatus.Success) { var token = result.ResponseData[0].Token; var token1 = new JObject { { "access_token", token } }; var user = await App.mobileServiceClient.LoginAsync( MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory, token1);

范围。


{ resourceId + "/user_impersonation" }

参考:
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/660#issuecomment-433831737


0
投票

© www.soinside.com 2019 - 2024. All rights reserved.