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 and it launches your browser but hangs when you hit allow, try copying the URL from the console into Chrome (assuming that it was a different browser like Safari that launched in the first place).
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 quickstart.py Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=111111222222233333333444444.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A55493%2F&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fspreadsheets.readonly&state=1111122223334444455555&access_type=offline Traceback (most recent call last): File "/Users/alans/workshop/quickstart.py", line 69, in <module> main() File "/Users/alans/workshop/quickstart.py", line 47, in main creds = flow.run_local_server(port=0) File "/Users/alans/workshop/venv/lib/python3.9/site-packages/google_auth_oauthlib/flow.py", line 478, in run_local_server authorization_response = wsgi_app.last_request_uri.replace("http", "https") AttributeError: 'NoneType' object has no attribute 'replace'