I got this code:
public async Task<MultipleAuthResult> Authenticate(string authority, string resource, string resource2, string clientId, string returnUri)
{
MultipleAuthResult multipleAuth = new MultipleAuthResult();
var authContext = new AuthenticationContext(authority);
if (authContext.TokenCache.ReadItems().Any())
authContext = new AuthenticationContext(authContext.TokenCache.ReadItems().First().Authority);
var uri = new Uri(returnUri);
var platformParams = new PlatformParameters((Activity)Xamarin.Forms.Forms.Context);
try
{
multipleAuth.ResultBackEnd = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
}
catch (AdalException e)
{
return null;
}
return multipleAuth;
}
When I try to get the token, in my Xamarin.Form droid, The Azure login page pop up I can log into it. After the Azure page close, but the line
multipleAuth.ResultBackEnd = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
never come back for the await. No exception, no visible error.
When I retry, Azure do not ask for my login information. The login page open and close rapidly. (Cached token I think). But my code do not go out from the await. What I do wrong? I use:
- Xamarin.Form 4.4
- Microsoft.IdentityModel.Clients.ActiveDirectory 5.2.7