Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google API client secrets error (Python)

I want to retrieve data from Google analytics. I have created a service account in the console and I am using Google's Python (hello_analytics_api_v3.py) code to access the data.

I have copied the client_secrets.json into my folder but get this error:

*SystemExit: 
WARNING: Please configure OAuth 2.0
To make this sample run you will need to populate the client_secrets.json file
found at:*

What should I do? I am using Python 2.7.

like image 667
Dirk Nachbar Avatar asked Dec 03 '22 00:12

Dirk Nachbar


2 Answers

Ensure the terminal is pointing to the same path directory as your client_secrets.json file.

i.e. type pwd in the console you're using to call the script and the output should match the directory of where client_secrets.json is stored.

like image 117
zsoobhan Avatar answered Dec 25 '22 09:12

zsoobhan


I was having this exact issue and deleted the credentials to my project and creating new ones using the 'OAuth client ID' option. Follow step one of this page closley https://developers.google.com/analytics/devguides/config/mgmt/v3/quickstart/installed-py

I also found a syntax error in the sample code provided by google The Lines:

print 'View (Profile): %s' % results.get('profileInfo').get('profileName')
print 'Total Sessions: %s' % results.get('rows')[0][0]

Should read:

print ('View (Profile): %s' % (results.get('profileInfo').get('profileName')))
print ('Total Sessions: %s' % (results.get('rows')[0][0]))

At least this solved it for me. Also, make sure the client_secrets.json is in the same directory as your python script.

like image 20
Preston Nicholls Avatar answered Dec 25 '22 11:12

Preston Nicholls