How to logout from microsoft in xamarin forms?

sagarsagar Member ✭✭
edited June 18 in Xamarin.Forms

I am working on xamarin forms. Where login is through Microsoft using AuthenticationContext. Once I click on login button it will redirect to a microsoft login page. login is working properly. Once I logged in from the user on logout button click user should be logged out, how to do logout no button click?

using the following code I am able to login

`public Task Authenticate(string authority, string resource, string clientId, string returnUri)
{
try
{
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 authResult = authContext.AcquireTokenAsync(resource, clientId, uri, platformParams);
        return authResult;
    }
    catch (Exception ex)
    {
        Crashes.TrackError(ex);
        return null;
    }
}`

Please help me how to log out?

Answers

Sign In or Register to comment.