Search code examples
c#wpfbrowseroauth-2.0azure-active-directory

OneDrive oauth wpf disable auto login browser


For connecting our application with OneDrive we are using oauth login....

But after logged in once it will reuse my credentials and i cannot cancel or use different account somehow it is cached.

I Also tried to delete Internet Explorer Cache and Cookies but still it will login.

    Uri uri = new Uri("https://login.microsoftonline.com/common/oauth2/v2.0/authorize?" +
        "&client_id=" + ClientId +
        "&response_type=code" +
        "&redirect_uri=" + RedirectUri +
        "&response_mode=query" +
        "&scope=offline_access%20Files.Read%20Files.Read.All%20Files.Read.Selected%20Files.ReadWrite%20Files.ReadWrite.All%20User.Read");
    WebBrowser.Navigate(uri);

Anyone now how to solve this in c# ?


Solution

  • To disable Single sign on just add a parameter to the request URI:

    "&prompt=select_account" or "&prompt=login"

    Reference: https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow