Forum Xamarin.Forms

OAuth Xamarin forms redirection occurs with authorisation code and not Token

I am using Xamarin.Auth nuget and following the sample for reference.

I'm using a third party Identity provider (Developed within my company). I get the authorization code alone in the redirected Url, but Google API gives me Token directly.

My query is does Xamarin.Auth support any ID provider? Am I doing anything wrong?

Button click code for calling the presenter

void Button_Clicked(Object sender, EventArgs e)
        {
            var authenticator = new OAuth2Authenticator(
                clientId: "myClientID",
                clientSecret: "myClientSecret",
                scope: "profile",
                authorizeUrl: new Uri(AuthroizationUri),
                redirectUrl: new Uri("sample.nikhil.com"),
                accessTokenUrl: new Uri(TokenUri),
                null,
                isUsingNativeUI: true);

            authenticator.Completed += Authenticator_Completed_2;
            authenticator.Error += Authenticator_Error_2;

            var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
            AuthenticationState.Authenticator = authenticator;
            presenter.Login(authenticator);
        }

Redirect activity code

    [Activity(Label = "Sample", NoHistory = true, LaunchMode = LaunchMode.SingleTop)]
    [IntentFilter(
    new[] { Intent.ActionView },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataSchemes = new[] { "redirect_schema" },
    DataPath = "/login")]
    public class LoginActivity : Activity
    {
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            var return_uri = new Uri(Intent.Data.ToString());

            var data = Intent.Data.ToString();

            char[] separator = { '=', '&' };

            var dataArray = data.Split(separator);
            AuthenticationState.returnCode = dataArray[1];
            // Load redirectUrl page
            AuthenticationState.Authenticator.OnPageLoading(return_uri);

            Finish();
            // Create your application here
        }
    }
Sign In or Register to comment.