redirect_uri_mismatch the redirect URI in the request does not match the ones authorized for the OAuth client

后端 未结 3 1292
悲&欢浪女
悲&欢浪女 2021-01-14 09:30

I have following client secret

{
  \"web\": {
    \"client_id\": \"testid\",
    \"project_id\": \"testproj\",
    \"auth_uri\": \"https://accounts.google.co         


        
相关标签:
3条回答
  • 2021-01-14 10:02

    I just ignored the port in the error message when adding as an Authorized redirect URL.

     http://127.0.0.1/authorize/
    
    0 讨论(0)
  • 2021-01-14 10:06

    The redirect uri is the URL where you want Google to return the authencation to. This should be the file that you have set up to handle the Oauth response.

    When you created your project in Google Developer console you should have supplied a redirect uri to google that states where you will be sending from and where you would like the response to be returned to.

    "Error: redirect_uri_mismatch The redirect URI in the request, http://127.0.0.1:8414/authorize/, does not match the ones authorized for the OAuth client.

    means that you are sending from http://127.0.0.1:8414/authorize/ however this is not one of the redirect uris that you have added in Google developer console. Go back to the developer console and add this http://127.0.0.1:8414/authorize/ or http://localhost:8414/authorize/ you may or may not need the ending / as well

    Bypass Login

    What you need to understand is that most of Googles api data is private user data. In order to access private user data you must have the consent of the user who owns that. We use Oauth2 to request from the user consent for our application to access their data. There is no way to by pass an oauth2 consent.

    Unfortunately there is no other way to access the YouTube api. If you want to access private user data you will always have to ask the user for consent at least once and then save the credentials as you are doing now using file data store.

    0 讨论(0)
  • 2021-01-14 10:10

    When you are creating your credentials in https://console.developers.google.com:

    After cliking on Create credentials by choosing OAuth client ID:

    Choose Other as Aplication type:

    Create OAuth client ID.

    You should have this format of credentials:

    {
      "installed": {
        "client_id": "...",
        "project_id": "...",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "token_uri": "https://oauth2.googleapis.com/token",
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "client_secret": "...",
        "redirect_uris": [
          "urn:ietf:wg:oauth:2.0:oob",
          "http://localhost"
        ]
      }
    }
    

    Now your OAuth2 link should works whatever your port in redirection_uri paramater as http://localhost:8414 for example (with 8414 as random port). And you are no more this error:

    Error: redirect_uri_mismatch The redirect URI in the request, http://localhost:8414/authorize/, does not match the ones authorized for the OAuth client.

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