8

I am trying to distribute my Xamarin Forms Android app via the Google Play Store in Visual Studio 2019.

I follow this tutorial by Microsoft: https://learn.microsoft.com/en-us/xamarin/android/deploy-test/publishing/publishing-to-google-play/?tabs=windows

I went through the steps of setting up a Google Developer Account as well as creating an application in the google dev console and an OAuth2 client.

I then entered the Client ID and Client Secret into the form and tried to register. Instead of being forwarded to the authorization page, I saw this error: Error 400: redirect_uri_mismatch

Unfortunately, I cannot just add the uri to the OAuth2 client, as the port changes every time I try to register button.

So, how can I solve this issue? Can I somehow fix the port that Visual Studio/Xamarin Forms uses? Is there an entirely different approach?

Your help is greatly appreciated.

2 Answers2

18

you need to create a Desktop App credential not a Web App in order to register from Visual Studio

VEGA
  • 288
  • 3
  • 9
  • I have spent HOURS trying to figure out what was going on - THANK YOU! This fixed, I'm not sure if my migraine will subside anytime soon though. You are a scholar and a gentleman (or woman). – Joshua Trimm Apr 17 '22 at 01:50
1

The problem here is that Visual Studio changes the IIS Express port numbers randomly when you try to register. To get around this, open the file:

[projectname].vs\config\applicationhost.config

Where [projectname] is the name of your project without the square brackets and scroll to the following nodes:

<binding protocol="http" bindingInformation="*:12345:localhost" />

Where "12345" is a random port that IIS assigned to that site. Remove the asterisk * so that you only have:

<binding protocol="http" bindingInformation=":12345:localhost" />

Do this for all the nodes like above. Save the file and then reopen VS. Distribute to Google Play, re-enter your Client ID and Client Secret and click register which should now show the allow access screen popup.

Jonty
  • 662
  • 7
  • 8