googleapis / google-auth-library-python-oauthlib

Apache License 2.0
186 stars 82 forks source link

fix: Update flow.py #349

Open octaflop opened 6 months ago

octaflop commented 6 months ago

This commit fixes a case in which a user has deleted the token.json and attempts to reauthorize. The user will find the reauthorization to work, but without the prompt=consent query parameter being sent to google's oauth, no new refresh_token will be sent.

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

Fixes #348 🦕

Feel free to make any other changes / updates.

personal workaround:

url_args = {
    'access_type': 'offline',
    'prompt': 'consent'
}
flow = InstalledAppFlow.from_client_secrets_file(
    str(credentials_path), SCOPES)
try:
    creds = flow.run_local_server(port=8080, open_browser=False, **url_args)

except MismatchingStateError:
    print("State mismatch error during OAuth process. Trying again...")
    creds = flow.run_local_server(port=8080, open_browser=False, **url_args)
google-cla[bot] commented 6 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.