I am using ADAL to access token from AzureAD. The Forms.Context is obsolete. So try the below But Have the below error message. How to fix it?
change this:
var platformParams = new PlatformParameters((Activity)Forms.Context);
To this:
var platformParams = new PlatformParameters(MainActivity.Instance, true, PromptBehavior.Always);
Error Message:
MainActivity does not contain a definition for Instance
public class AuthenticationService:IAuthenticationService
{
public async Task<AuthenticationResult> Authenticate(string authority, string resource, string clientId, string returnUri)
{
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)Forms.Context);
var platformParams = new PlatformParameters(MainActivity.Instance, true, PromptBehavior.Always);
var authResult = await authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
return authResult;
}
}
Thanks