Forum Xamarin.Android

Login with Xamarin.Auth using Microsoft Account does not redirect

abitzanabitzan Member ✭✭
edited January 2020 in Xamarin.Android

Hello everyone!

I built an app where it is possible to login with Google or your Microsoft account.
I followed the respective Tutorial on how to use Xamarin.Auth for Google services, which worked out perfectly.
With the help of the Microsoft OAUTH workflow Tutorial, I was able to register my app in Azure, and implement the Login like this:

                  var authenticator = new OAuth2Authenticator(
                new Uri(""),
                new Uri(""),
                new Uri(""),

                authenticator.Completed += OnAuthCompleted;
                authenticator.Error += OnAuthError;

                AuthenticationState.Authenticator = authenticator;

                var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();

I also applied a listener, to see if the response works

authenticator.Completed += OnAuthCompleted;

Now if I press the Microsoft login button, the correct website opens in the native browser, I fill in the credentials and get fowarded to an empty page

However, the URL of this empty page is already filled with the code, as stated in the Microsoft OAUTH workflow Tutorial

The URL looks like this:

Which is exactly how it should look like, but I get no response inside the app. Seems like the default redirect URL for mobile devices

is not working?

My expected behaviour is that the app opens again and the Completed event is fired, as it already works with the Google login.
Unfortunately the Microsoft docs only feature a Google example.

How do I get the code stated in the URL inside my app?

Thank you


  • LandLuLandLu Member, Xamarin Team Xamurai

    Have you configured the redirect process on each platform?
    i.e. on iOS, we need to add a custom url scheme:

    This url must match with the application which is registered on the Google Api Console:

    We also need to configure it in the Constants class:

    public static string iOSRedirectUrl = "<insert iOS redirect URL here>:/oauth2redirect";
    public static string AndroidRedirectUrl = "<insert Android redirect URL here>:/oauth2redirect";

    Please follow this documentation:

Sign In or Register to comment.