尋找通過Azure AD B2C進行身份驗證的Xamarin Forms開發的Azure移動服務示例。我有一個工作解決方案,可以使用Xamarin Forms中的Azure B2C進行身份驗證,但無法在Azure移動服務中使用生成的令牌。見下面的代碼片段:Azure AD B2C Azure移動服務Xamrin表單示例
public static PublicClientApplication AuthenticationClient { get; private set; }
public static MobileServiceClient MobileService = new MobileServiceClient(Constants.MobileServiceClientName);
result = App.AuthenticationClient.AcquireTokenAsync(
Constants.Scopes,
string.Empty,
UIBehavior.SelectAccount,
string.Empty,
null,
Constants.Authority, null);
JObject objToken = new JObject();
objToken.Add("authenticationToken", result.IdToken);
//I am successfully able to get an Id token for Microsoft, Google and Twitter providers but when I use the token to login to my Azure Mobile Service app, I get a "Not Authorized" error
MobileServiceUser user = await MobileService.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount, objToken);
任何和所有的想法,讚賞。
查看上面的代碼更改: – sidsud
查看上面的代碼更改:objToken.Add(「authenticationToken」,result.IdToken);已更改爲objToken.Add(「access_token」,result.IdToken),並且我已將MobileServiceAuthenticationProvider.MicrosoftAccount更改爲MobileServiceAuthenticationProvider.WindowsAzzureActiveDirectory – sidsud