Azure AD B2C Azure 移动服务 Xamarin 表单示例
Azure AD B2C Azure Mobile Services Xamrin Forms Example
正在寻找在 Xamarin Forms 中开发并通过 Azure AD B2C 进行身份验证的 Azure 移动服务示例。我有一个可行的解决方案,我可以在 Xamarin Forms 中使用 Azure B2C 进行身份验证,但无法在 Azure 移动服务中使用生成的令牌。请参阅下面的代码片段:
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);
欢迎任何想法。
我能够解决问题。我的 Azure 移动应用程序上的 Azure AD 提供程序配置配置不正确。
这是更正后的代码:
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("access_token", 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.WindowsAzureActiveDirectory, objToken);
如果有人感兴趣,我可以提供有关 Azure AD 配置的更多详细信息。所以现在,我有一个完全可用的 Xamarin Forms Azure 移动应用程序,它使用 Azure AD B2C 进行身份验证,目前与 Microsoft、Google 和 Twitter 提供商合作。
正在寻找在 Xamarin Forms 中开发并通过 Azure AD B2C 进行身份验证的 Azure 移动服务示例。我有一个可行的解决方案,我可以在 Xamarin Forms 中使用 Azure B2C 进行身份验证,但无法在 Azure 移动服务中使用生成的令牌。请参阅下面的代码片段:
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);
欢迎任何想法。
我能够解决问题。我的 Azure 移动应用程序上的 Azure AD 提供程序配置配置不正确。
这是更正后的代码:
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("access_token", 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.WindowsAzureActiveDirectory, objToken);
如果有人感兴趣,我可以提供有关 Azure AD 配置的更多详细信息。所以现在,我有一个完全可用的 Xamarin Forms Azure 移动应用程序,它使用 Azure AD B2C 进行身份验证,目前与 Microsoft、Google 和 Twitter 提供商合作。