python-samples: flow.run_local_server() raises AttributeError

Expected Behavior

Work fine as here: https://developers.google.com/gmail/api/quickstart/python.

Actual Behavior

After clicking “Allow” button (second time) in browser and redirection to local page, browser shows “This site can’t be reached” error. In console script, the following error occurs:

Traceback (most recent call last):
  File "script.py", line 48, in <module>
    main()
  File "script.py", line 29, in main
    creds = flow.run_local_server(port=8088)
  File "/Users/stasdeep/.virtualenvs/gmail/lib/python3.6/site-packages/google_auth_oauthlib/flow.py", line 418, in run_local_server
    authorization_response = wsgi_app.last_request_uri.replace(
AttributeError: 'NoneType' object has no attribute 'replace'

Steps to Reproduce the Problem

  1. Create a virtualenv: mkvirtualenv -p python3.6 gmail
  2. Enable Gmail API
  3. Install requirements: pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
  4. Run the quickstart script: python quickstart.py

Specifications

  • Python 2.7/3.6 (envs created with virtualenvwrapper)
  • macOS Mojave 10.14.1

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 17

Most upvoted comments

I am still having this issue. Tried doing it in Incognito and it still isn’t working.

I had the same issue. I ended up switching to the Chrome browser from Safari and it worked, weird but it worked for me.

I am facing this issue any fix

I had a similar issue the first time I ran the python quickstart.py command, but tried a second time (without install anything else) and it ran fine.

Had this problem as well in Safari; but it worked when I put the authorization url into FireFox.