You Have To Use Chrome To Authorize A Python Desktop App API Connection To Google Sheets


If you've setup everything for the Google Sheets API Python Sample.

Some folks reported having to do an incognito browser window or needing to use Firefox. Your milage may vary.

When I ran the app, it opened safari where I clicked through to allow access but then it hung and finally chocked with a message from the browser about not being able to find a localhost server.

Turns out the solution was to copy the URL that shows up in the console and paste it into chrome.

Took me a bit to find that answer via this page. Pasting this here in hopes it helps folks find the answer faster.

$ python
Please visit this URL to authorize this application:
Traceback (most recent call last):
  File "/Users/alans/workshop/", line 69, in <module>
  File "/Users/alans/workshop/", line 47, in main
    creds = flow.run_local_server(port=0)
  File "/Users/alans/workshop/venv/lib/python3.9/site-packages/google_auth_oauthlib/", line 478, in run_local_server
    authorization_response = wsgi_app.last_request_uri.replace("http", "https")
AttributeError: 'NoneType' object has no attribute 'replace'