google-auth-library-python-oauthlib icon indicating copy to clipboard operation
google-auth-library-python-oauthlib copied to clipboard

fix: Update flow.py

Open octaflop opened this issue 1 year ago • 1 comments

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:

  • [x] Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • [ ] Ensure the tests and linter pass
  • [ ] Code coverage does not decrease (if any source code was changed)
  • [ ] Appropriate docs were updated (if necessary)

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)

octaflop avatar May 06 '24 20:05 octaflop

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.

google-cla[bot] avatar May 06 '24 20:05 google-cla[bot]