Giter VIP home page Giter VIP logo

Comments (15)

busunkim96 avatar busunkim96 commented on September 1, 2024 9

When you do figure out the solution, would you mind posting back here? It will help who stumbles on this issue in the future. 😃

from google-auth-library-python-oauthlib.

Andras1000 avatar Andras1000 commented on September 1, 2024 2

This happened to me after trying to use the OAuth2 authorization code more then once.

The solution for me was to get a fresh authorization code.

from google-auth-library-python-oauthlib.

cinjon avatar cinjon commented on September 1, 2024

I changed this to use a site-specific redirect uri and now I'm getting:

oauthlib.oauth2.rfc6749.errors.CustomOAuth2Error: (redirect_uri_mismatch) Bad Request

This seems pretty common but none of the solutions I see are working for me.

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

Hiya @cinjon

I think you're running into a bug introduced in v0.4.0. Please use 0.3.0 until the fix is released in 0.4.1

from google-auth-library-python-oauthlib.

cinjon avatar cinjon commented on September 1, 2024

I tried downgrading and am still getting the same error:

oauthlib.oauth2.rfc6749.errors.CustomOAuth2Error: (redirect_uri_mismatch) Bad Request

from google-auth-library-python-oauthlib.

cinjon avatar cinjon commented on September 1, 2024

Is there a way to get more visibility into what is the error? All I'm seeing is oauthlib.oauth2.rfc6749.errors.CustomOAuth2Error: (redirect_uri_mismatch) Bad Request but the redirect_uri is the same on both the client and the server.

(@cc @busunkim96 )

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

Hmm, can verify that the desired redirect_uri is in the credentials.json file? It should be listed under the redirect_uris field.

from google-auth-library-python-oauthlib.

cinjon avatar cinjon commented on September 1, 2024

So that was an issue, and I've now updated it - and I still get the same error. Fwiw, this is all happening in local development.

My current credentials.json looks like:
{"web":{"client_id":"<blah>.apps.googleusercontent.com","project_id":"<blah>","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":"<blah>","redirect_uris":["https://localhost:3000/google_oauth_redirect","http://localhost:3000/google_oauth_redirect","http://localhost:5000/google_oauth_redirect","https://localhost:5000/google_oauth_redirect"],"javascript_origins":["https://localhost:3000","http://localhost:3000","https://localhost:5000","http://localhost:5000"]}}

As you can see, I have inserted all the things I could think of to try and get it to not be a mismatch. I've also tried the redirect_uri combinations in my local JS as well.

Do you have more suggestions? That last one was really useful. Thanks!

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

@cinjon Did you edit the file manually? If so, you should go to the API console and edit your existing OAuth client ID. After that you can re-download the credentials.

from google-auth-library-python-oauthlib.

cinjon avatar cinjon commented on September 1, 2024

I didn't. I downloaded it from the console.

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

It looks like the library you linked is using gapi under the hood. You might want to take a look at that documentation as well.

https://developers.google.com/identity/sign-in/web/reference#gapiauth2clientconfig
image

There are some more general suggestions in this stackoverflow post.

from google-auth-library-python-oauthlib.

jahangirkabir avatar jahangirkabir commented on September 1, 2024

I am also getting the same error with version 0.4.2

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

Revisiting this, I think @Andras1000 is correct.

To get a new access token you need to use the refresh token.
image

Documentation:

from google-auth-library-python-oauthlib.

bhavaygg avatar bhavaygg commented on September 1, 2024

@busunkim96 How do i get the refresh token tho? I have got the authorization code from the front end and want to store the refresh token in my django backend.

from google-auth-library-python-oauthlib.

busunkim96 avatar busunkim96 commented on September 1, 2024

@Chokerino The authorization code should be exchanged for a refresh token. https://developers.google.com/identity/protocols/oauth2/web-server#exchange-authorization-code

from google-auth-library-python-oauthlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.