【发布时间】:2016-11-07 04:29:51
【问题描述】:
我对 Xamarin 和 Azure Active Directory 有点陌生,所以请多多包涵。我在尝试从 Azure Active Directory 检索用户信息(名字、姓氏和图片)时遇到问题。请注意,Azure Active Directory 中的电子邮件是 Google 帐户。
每次我尝试检索它时,我只会收到一个错误,并且它需要我再次进行身份验证才能检索我想要的内容。这是我的代码:
// 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 放什么。
【问题讨论】:
标签: c# android azure xamarin xamarin.android