0

I am developing an application with Xamarin.Android and i needed login system. Therefore i'm using Xamarin.Auth. I create a OAuth2Authenticator but not working auth.completed . How fire auth.completed on succeeded?

public void LoginToSabis()
            {
                var auth = new OAuth2Authenticator(
                    clientId: "example_android",
                    scope: "read",
                    authorizeUrl: new Uri("example/authorize"),
                    redirectUrl: new Uri("ex/callback"));

            auth.AllowCancel = true;



        // If authorization succeeds or is canceled, .Completed will be fired. BUT WHEN SUCCEEDS NOT WORKING, WHEN CANCELED WORKING...
        auth.Completed += async (s, ee) =>
        {


            if (!ee.IsAuthenticated)
            {

                var builder = new Android.Support.V7.App.AlertDialog.Builder(this);
                builder.SetMessage("Not Authenticated");
                builder.SetPositiveButton("Ok", (o, e) => { });
                builder.Create().Show();
                return;
            }

            AccountStore.Create(Application.Context).Save(ee.Account, "cg");
            StartActivity(typeof(LoginRedirectActivity));
            };
}
Cenk Gun
  • 41
  • 6

1 Answers1

0

Prior to version 1.4.x Xamarin.Auth needed real (existing) endpoint and it tried to load it in embedded WebView, so your problem was:

redirectUrl: new Uri("ex/callback")

You need something like http://somehost.top.level.domain. NOTE: localhost will not work withnolder versions of Xamarin.Auth.

Since version 1.4.0 some of those restrictions were removed and redirect_url with custom schemes were allowed.

moljac
  • 946
  • 9
  • 12