3

I am trying to upload video to YouTube through MVC C# application. I am following this link

Whenever I am trying to run the application I am getting below error from the Google.

Error: redirect_uri_mismatch

The redirect URI in the request, http://localhost:52271/authorize/, does not match the ones authorised for the OAuth client. Visit https://console.developers.google.com/apis/credentials/oauthclient/CCC-XXX.apps.googleusercontent.com?project=XXXX to update the authorised redirect URIs.

Here is my Json file. enter image description here

Here is my Google Console Application: enter image description here

Error: enter image description here

Is there anything wrong ?

Thank You.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Chandresh Khambhayata
  • 1,748
  • 2
  • 31
  • 60
  • Possible duplicate of [Google OAUTH: The redirect URI in the request did not match a registered redirect URI](http://stackoverflow.com/questions/22595174/google-oauth-the-redirect-uri-in-the-request-did-not-match-a-registered-redirec) – Koby Douek Mar 11 '17 at 07:51

3 Answers3

2

The redirect URI you set in Google Developer console must exactly match where you are sending the request from. If you notice the Port number is changing. This is because visual studio has a habit of adding random port numbers when you are debugging via visual stuido.

To specify a port for a Web application project that uses IIS Express

  1. In Solution Explorer, right-click on the project and then select Properties. Click the Web tab.
  2. In the Servers section, under Use Local IIS Web server, in the Project URL box change the port number.
  3. To the right of the Project URL box, click Create Virtual Directory, and then click OK.
  4. In the File menu, click Save Selected Items.
  5. To verify the change, press CTRL+F5 to run the project. The new port number appears in the address bar of the browser.

How to: Specify a Port for the ASP.NET Development Server

Luis Teijon
  • 4,769
  • 7
  • 36
  • 57
Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
1

From Google doc located at https://developers.google.com/identity/protocols/OAuth2UserAgent?hl=en_US#example The REDIRECT_URI should be the same URL where the page is being served. I finally saw this, put the URL for the page where I call the Google authentication, and it worked like a charm.

JNickVA1
  • 418
  • 7
  • 23
-1

You need to add localhost to your authorized domain names in the Google API Console.

Koby Douek
  • 16,156
  • 19
  • 74
  • 103