Forum Xamarin.Forms

How to logout from microsoft in xamarin forms?

sagarsagar Member ✭✭✭
edited June 2019 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)
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)
        return null;

Please help me how to log out?


Sign In or Register to comment.