Google OAuth 2 authorization - Error: redirect_uri_mismatch

前端 未结 30 1927
遥遥无期
遥遥无期 2020-11-22 02:58

On the website https://code.google.com/apis/console I have registered my application, set up generated Client ID: and Client Secret to my a

相关标签:
30条回答
  • 2020-11-22 03:17

    Try to do these checks:

    1. Bundle ID in console and in your application. I prefer set Bundle ID of application like this "org.peredovik.${PRODUCT_NAME:rfc1034identifier}"
    2. Check if you added URL types at tab Info just type your Bundle ID in Identifier and URL Schemes, role set to Editor
    3. In console at cloud.google.com "APIs & auth" -> "Consent screen" fill form about your application. "Product name" is required field.

    Enjoy :)

    0 讨论(0)
  • 2020-11-22 03:20

    In my case it was www and non-www URL. Actual site had www URL and the Authorized Redirect URIs in Google Developer Console had non-www URL. Hence, there was mismatch in redirect URI. I solved it by updating Authorized Redirect URIs in Google Developer Console to www URL.

    Other common URI mismatch are:

    • Using http:// in Authorized Redirect URIs and https:// as actual URL, or vice-versa
    • Using trailing slash (http://example.com/) in Authorized Redirect URIs and not using trailing slash (http://example.com) as actual URL, or vice-versa

    Here are the step-by-step screenshots of Google Developer Console so that it would be helpful for those who are getting it difficult to locate the developer console page to update redirect URIs.

    1. Go to https://console.developers.google.com

    2. Select your Project

    1. Click on the menu icon

    1. Click on API Manager menu

    1. Click on Credentials menu. And under OAuth 2.0 Client IDs, you will find your client name. In my case, it is Web Client 1. Click on it and a popup will appear where you can edit Authorized Javascript Origin and Authorized redirect URIs.

    Here is a Google article on creating project and client ID.

    0 讨论(0)
  • 2020-11-22 03:21

    for me it was because in the 'Authorized redirect URIs' list I've incorrectly put https://developers.google.com/oauthplayground/ instead of https://developers.google.com/oauthplayground (without / at the end).

    0 讨论(0)
  • 2020-11-22 03:21

    Let me complete @Bazyl's answer: in the message I received, they mentioned the URI "http://localhost:8080/" (which of course, seems an internal google configuration). I changed the authorized URI for that one, "http://localhost:8080/" , and the message didn't appear anymore... And the video got uploaded... The APIS documentation is VERY lame... Every time I have something working with google apis, I simply feel "lucky", but there's a lack of good documentation about it.... :( Yes, I got it working, but I don't yet understand neither why it failed, nor why it worked... There was only ONE place to confirm the URI in the web, and it got copied in the client_secrets.json... I don't get if there's a THIRD place where one should write the same URI... I find nor only the documentation but also the GUI design of Google's api quite lame...

    0 讨论(0)
  • 2020-11-22 03:21

    In my case I had to check the Client ID type for web applications/installed applications.

    installed applications: http://localhost [Redirect URIs] In this case localhost simply works

    web applications: You need valid domain name [Redirect URIs:]

    0 讨论(0)
  • 2020-11-22 03:22

    I had two request URIs in the Console, http://xxxxx/client/api/spreadsheet/authredirect and http://localhost.

    I tried all the top responses to this question and confirmed that none of them were my problem.

    I removed localhost from the Console, updated my client_secret.json in my project, and the mismatch error went away.

    0 讨论(0)
提交回复
热议问题