Redirect URL for google oauth?

Billy12ShovelsBilly12Shovels USUniversity ✭✭✭


Does anyone know the default redirect url for google oauth? I have tried logic based on this github link(line 18):

and that does not work. Any ideas?



Best Answer


  • RobStellerRobSteller USMember ✭✭

    Were you able to figure this out?

  • Billy12ShovelsBilly12Shovels USUniversity ✭✭✭
    Accepted Answer

    I was using "xamarin-auth://localhost" as the redirecut url, but I ended up not implementing the functionality and instead used Auth0 for my login flow.

  • RobStellerRobSteller USMember ✭✭


  • moljacmoljac HRBeta ✭✭✭

    xamarin-auth://localhost is indeed custom url, but it can be used (with google) only with "Other" app/client type.

    You must read google docs during setup of the OAuth provider - for Android it has 2 options (based on package id from AndroidManifest.xml and google product id - the second one works the best). IOS has different setup (Info.plist and any kind of scheme). If you add UWP to that you will have new issues, but solvable. The same is valid for Xamarin.Forms.

    Basically it is not trivial and needs some planing.

  • I am trying to use "com.googleusercontent.apps.5**************"; as a redirect url but it can not be converted to an uri and use it in the OAuth2Authenticator.

  • KlinguKlingu USMember ✭✭

    @BrunoPasquini.7813 said:
    I am trying to use "com.googleusercontent.apps.5**************"; as a redirect url but it can not be converted to an uri and use it in the OAuth2Authenticator.

    You should add ":/oauth2redirect" at the end of your redirectUrl. Like below ;-)


    Allmost there ;-)

  • AlexOwensAlexOwens USMember

    I am attempting to use the OAuth2Authenticator as well, I've added the :/oauth2redirect to my reverse client Id; however, when I login using this method, I see a google search page. Any ideas/suggestions? I am attempting to use the custom uri scheme interception, but I don't think it's being intercepted to that activity.

    Here is the activity:
    [IntentFilter ( actions: new[] { Intent.ActionView }, Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable }, DataSchemes = new[] { "com.googleusercontent.apps.<clientId>", "urn:ietf:wg:oauth:2.0:oob","xamarin-auth" }, DataHosts = new[] { "localhost", "authorize", }, DataPaths = new[] {"/", "/oauth2redirect", "/oauthredirect" }, AutoVerify = true ) ]

    here is the Authenticator creation:
    Authenticator = new OAuth2Authenticator(c.ClientId,null,c.Scope,c.AuthUrl,c.RedirectUrl,c.AccessTokenUri,null,true); Authenticator.ShowErrors = false; Authenticator.AllowCancel = true;

            var intent =  Authenticator.GetUI(this);

    redirect uri is this: RedirectUrl = new Uri("com.googleusercontent.apps.<clientId>:/oauth2redirect"),

  • tbycidiottbycidiot Member

    Were you able to figure this out? Having the exact same problem. Thanks!

  • MattRobbMattRobb GBUniversity

    I am having the same problem on IOS . And I am keen to resolve it; please help! I log on successfully but the redirect does not work! Just like AlexOwens above I am using "com.googleusercontent.apps.MyclientId:/oauth2redirect" as my redirect. I have confirmed that the redirect is correct in my Info.plist too. I can login correctly, then I get the message Safari cannot open the page because the address is invalid.

    I have done all the Reset Safari and delete its history suggestions which were suggested elsewhere. That had no effect.

    Please advise soonest.



  • MattRobbMattRobb GBUniversity

    Resolved! Unbelievably after messing about with this for a couple of hours I have resolved the problem, by re-reading the Google Instructions.

    Basically you use 2 variants of the Redirect Uri:

    In your Xamarin code using the package Xamarin.Auth, you include :/oauth2redirect to your Redirect url (without doing that you will receive an error). Just as Xamarin suggests.

    Then in the info.plist You only use: "com.googleusercontent.apps.MyclientId" (without adding :/oauth2redirect). And it will work correctly.

    I have attached the piece of Google documentation which made the format of the URL clear.

  • SweeHengCheahSweeHengCheah USMember ✭✭

    How to implement this for Android?

  • EdwardLinaresEdwardLinares USMember ✭✭

    Same here, Android always after a successful authentication go to the google search page, why?

  • microwalesmicrowales Member
    edited April 20

    If you are having issue with redirect in android customtab. use xamarin.auth for now.
    https : // github .com/xamarin/Xamarin.Auth/issues/275#issuecomment-423780272
    https : // forums.xamarin .com/discussion/100286/xamarin-auth-android-chrome-custom-tabs-doesnt-close-on-redirect
    (i cant post links yet so remove the space :wink: )
    Version 1.6.x works fine in android btw.

Sign In or Register to comment.