The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

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

TODO: Pull subtitle into page object

TL;DR

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.

code_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

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

-- p

TL;DR

-- p

If you've setup everything for the <<link|Google Sheets API Python Sample|https://developers.google.com/sheets/api/quickstart/python) 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>>.

-- p

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

-- p

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.

-- p

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

-- p

Took me a bit to find that answer via <<link|this page|https://github.com/googleworkspace/python-samples/issues/88>>. Pasting this here in hopes it helps folks find the answer faster.

-- code/

$ 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'

-- /code


-- categories
-- Python

-- metadata
-- date: 2021-08-31 21:54:36
-- id: 20eopikl
-- status: published
-- type: post
-- SCRUBBED_NEO: false
-- site: aws