Comments (15)
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.
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.
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.
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.
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.
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.
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.
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.
@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.
I didn't. I downloaded it from the console.
from google-auth-library-python-oauthlib.
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
There are some more general suggestions in this stackoverflow post.
from google-auth-library-python-oauthlib.
I am also getting the same error with version 0.4.2
from google-auth-library-python-oauthlib.
Revisiting this, I think @Andras1000 is correct.
To get a new access token you need to use the refresh token.
Documentation:
- https://developers.google.com/identity/protocols/oauth2
- https://developers.google.com/identity/protocols/oauth2/web-server#offline
from google-auth-library-python-oauthlib.
@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.
@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)
- appflow.run_console() is deprecated fix building auth url HOT 2
- The flow.run_console() function cannot be found. HOT 3
- Wrong Docs in google_auth_oauthlib.get_user_credentials?
- py.typed marker is missing HOT 1
- Ability to read client secrets from an external source like google secret manager HOT 1
- Support for Google identity platform multi-tenancy
- Feature Request: Ability to specify an OAuth audience to InstalledAppFlow.run_local_server HOT 3
- tests.unit.test_flow.TestInstalledAppFlow: test_run_local_server_code_verifier failed HOT 1
- Ability to specify browser during authentication
- Mismatch in credentials.json keys and that expected by this library. HOT 3
- tests.unit.test_flow.TestInstalledAppFlow: test_run_local_server_audience failed HOT 1
- Update metadata setup.py
- run_local_server does not seem to release its port if an Exception is raised HOT 3
- Support Private Network Access for Chrome
- InstalledAppFlow for web applications HOT 2
- Refresh_token not regenerated with current authorization_url defaults. HOT 4
- Flow.autogenerate_code_verifier does not default to True and flow.code_verifier is None
- tests.unit.test_flow.TestInstalledAppFlow: test_run_local_server_occupied_port failed HOT 2
- Warning: a recent release failed HOT 1
- Unable to authenticate using google-oauthlib-tool HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-auth-library-python-oauthlib.