0

I have the following Python code to connect to my a Google spreadsheet I own. The API credential is stored on a Dropbox folder which is synchronized to both my Windows machine and my mac. I have checked that the URLs for the folder are correct for each system.

if sys.platform == 'win32':
    weight_folder = #path to Dropbox folder on my Windows machine
else:
    weight_folder = #path to Dropbox folder on my Mac


client_id = 'redacted'
client_secret = 'redacted'
height = 182

flow = oauth2client.client.OAuth2WebServerFlow(client_id, client_secret, 'https://spreadsheets.google.com/feeds https://www.googleapis.com/auth/drive')
storage = oauth2client.file.Storage('credentials_weight.dat')
credentials = storage.get()
if credentials is None or credentials.invalid:
    import argparse
    flags = argparse.ArgumentParser(parents=[oauth2client.tools.argparser]).parse_args([])
    credentials = oauth2client.tools.run_flow(flow, storage, flags)
gc = gspread.authorize(credentials)

This works totally fine when I run it on my windows machine. When I run it on my mac however, I get the message

Failed to start a local webserver listening on either port 8080 or port 8090. Please check your firewall settings and locally running programs that may be blocking or using those ports. Falling back to --noauth_local_webserver and continuing with authorization. Go to the following link in your browser:

Following the link gives me the following message

Error 400: invalid_request. You can't sign in to this app because it doesn't comply with Google's OAuth 2.0 policy for keeping apps secure.

I am not very skilled with Google's APIs, but I don't understand why the app would be authorized on Windows but not authorized on mac. It feels like the error message is not accurate.

What could cause this?

1
  • last one normally meahs you are using http and not https. Wonder if this is just an issue with the configuration of your ide on mac Commented Jul 20, 2022 at 11:02

1 Answer 1

0

Based off the message on the link, I do think it's something related to the Google API settings. There are a couple of different possible solutions on this post which seem relevant to your case.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.