我对Xamarin和Azure Active Directory有点新鲜,所以请耐心等待。我在尝试从Azure Active Directory检索用户信息(名字,姓氏和图片)时遇到问题。请注意,Azure Active Directory中的电子邮件是Google帐户。
每次我尝试检索它时,我只会收到一个错误,并且我需要对AGAIN进行身份验证才能检索我想要的内容。这是我的代码:
// Use MobileServices Login to authenticate user
private async Task<bool> AuthenticateUsingMobileServices(Activity activity)
{
var success = false;
try
{
// Sign in with Active Directory
MobileUser = await MobileService.LoginAsync(activity,
MobileServiceAuthenticationProvider.WindowsAzureActiveDirectory);
System.Diagnostics.Debug.WriteLine("you are now logged in - Logged in!");
System.Diagnostics.Debug.WriteLine([insert user name here]);
success = true;
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine("Authentication failed " + ex.ToString());
}
}
除了我已经定义的ResourceUri和ClientId之外,我还尝试添加它:
AuthenticationContext authContext = new AuthenticationContext(CommonAuthority);
AuthResult = await authContext.AcquireTokenAsync(ResourceUri, ClientId, UserCredential);
但我对ClientAssertion或UserAssertion的内容毫无头绪。
答案 0 :(得分:0)
您需要做的步骤是:
退房:https://blog.xamarin.com/authenticate-xamarin-mobile-apps-using-azure-active-directory/