googleapis / google-auth-library-python-oauthlib

Apache License 2.0
188 stars 82 forks source link

InstalledAppFlow run_local_server wsgi_app.last_request_uri / AttributeError: 'NoneType' object has no attribute 'replace' #109

Open bVTiger opened 3 years ago

bVTiger commented 3 years ago

Hello.

The local server shuts down too quickly - it is not enough for authentication in browser. It would be nice if it was possible to set a timeout during which the server does not shutdown.

Python 3.7.4

trace:

Traceback (most recent call last):
  File "...../chatter.py", line 226, in logIn
    success_message=self.cfg.google_success_message)
  File "......../lib/python3.7/site-packages/google_auth_oauthlib/flow.py", line 473, in run_local_server
    authorization_response = wsgi_app.last_request_uri.replace("http", "https")
AttributeError: 'NoneType' object has no attribute 'replace'

source:

flow = InstalledAppFlow.from_client_config(self.cfg.google_client_config,
                    scopes=['openid',
                            'https://www.googleapis.com/auth/userinfo.email',
                            'https://www.googleapis.com/auth/userinfo.profile'])
credentials = flow.run_local_server(port=0, success_message=self.cfg.google_success_message)

pip freeze:

alabaster==0.7.12
arabic-reshaper==2.0.15
astroid==2.4.2
astunparse==1.6.3
Babel==2.8.0
cachetools==4.2.1
certifi==2019.11.28
cffi==1.14.0
chardet==3.0.4
cryptography==2.8
cycler==0.10.0
decorator==4.4.2
distro==1.4.0
docutils==0.16
dukpy==0.2.2
esprima==4.0.1
et-xmlfile==1.0.1
freetype-py==2.1.0.post1
future==0.18.2
gevent==1.4.0
gitdb==4.0.2
GitPython==3.1.0
glfw==1.11.0
google-api-core==1.26.2
google-api-python-client==2.0.2
google-auth==1.24.0
google-auth-httplib2==0.1.0
google-auth-oauthlib==0.4.3
googleapis-common-protos==1.53.0
greenlet==0.4.15
gunicorn==20.0.4
html2text==2020.1.16
httplib2==0.19.0
idna==2.9
imageio==2.8.0
imageio-ffmpeg==0.4.1
imagesize==1.2.0
isort==5.6.4
javascripthon==0.10
jdcal==1.4.1
Jinja2==2.11.1
json-tricks==3.14.0
kiwisolver==1.1.0
lazy-object-proxy==1.4.3
macropy3==1.1.0b2
MarkupSafe==1.1.1
matplotlib==3.2.0
mccabe==0.6.1
moviepy==1.0.1
msgpack==1.0.0
msgpack-numpy==0.4.4.3
numexpr==2.7.1
numpy==1.18.1
oauthlib==3.1.0
opencv-python==4.2.0.32
openpyxl==3.0.3
packaging==20.4
pandas==1.0.1
pefile==2019.4.18
Pillow==7.0.0
proglog==0.1.9
protobuf==3.15.6
psutil==5.7.0
PsychoPy==2020.1.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.20
pydash==4.8.0
pyglet==1.5.0
Pygments==2.6.1
pylint==2.6.0
PyOpenGL==3.1.5
pyOpenSSL==19.1.0
pyosf==1.0.5
pyparallel==0.2.2
pyparsing==2.4.6
PyQt5==5.14.1
PyQt5-sip==12.7.1
pyserial==3.4
python-bidi==0.4.2
python-dateutil==2.8.1
python-gitlab==2.0.1
pytz==2019.3
PyYAML==5.3
pyzmq==19.0.0
questplus==2019.4
requests==2.23.0
requests-oauthlib==1.3.0
rsa==4.7
scipy==1.4.1
six==1.14.0
smmap==3.0.1
snowballstemmer==2.0.0
sounddevice==0.3.14
SoundFile==0.10.3.post1
Sphinx==3.1.1
sphinx-markdown-builder==0.5.4
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4
tables==3.6.1
toml==0.10.2
tqdm==4.43.0
typed-ast==1.4.1
tzlocal==2.1
unify==0.5
untokenize==0.1.1
uritemplate==3.0.1
urllib3==1.25.8
wrapt==1.12.1
wxPython==4.0.7.post2
xarray==0.15.0
xlrd==1.2.0
xmltodict==0.12.0
yapf==0.30.0
busunkim96 commented 3 years ago

Hi @bVTiger,

When I've used run_local_server it generally doesn't time out until the user has clicked through and authenticated. How quickly is the timeout happening? run_console is another option if you're in a situation where it's difficult to open the browser for the user.

bVTiger commented 3 years ago

Hi @busunkim96

When I've used run_local_server it generally doesn't time out until the user has clicked through and authenticated. How quickly is the timeout happening? run_console is another option if you're in a situation where it's difficult to open the browser for the user.

after 20..23 seconds approx. run_console not very suitable for my task

dpmartee commented 2 years ago

Same issue here:

File "..........\venv\lib\site-packages\google_auth_oauthlib\flow.py", line 504, in run_local_server authorization_response = wsgi_app.last_request_uri.replace("http", "https") AttributeError: 'NoneType' object has no attribute 'replace'

The server shut down too quickly. I've tried to add open_browser=False to run_local_server to verify old issues and in less than 2 seconds python rise that error.

run_console is also now deprecated

pembo13 commented 1 year ago

I'm having basically the same issue, except run_console doesn't even exist anymore.