measureallthethings
measureallthethings

Reputation: 1102

Google API client_secrets error

I just installed Anaconda (with Python 3 as default), as I need it for pandas/accessing Google Analytics. Here is some info about accessing GA through Python & pandas: http://pandas.pydata.org/pandas-docs/stable/remote_data.html#remote-data-ga

A similar question was asked here Google API client secrets error (Python) but the answer does not seem helpful in my particular case. Namely, the error I have is different; I've placed the client_secrets.json file in the appropriate directory; the file is not empty and has the exact same contents as shown in the developer console.

Here is the code and error:

import numpy as np
import pandas as pd
import pandas.io.ga as ga
from pandas import Series, DataFrame

df = ga.read_ga(metrics='sessions', dimensions='date', start_date='2015-07-01')

An exception has occurred, use %tb to see the full traceback.

SystemExit:
WARNING: Please configure OAuth 2.0

You need to populate the client_secrets.json file found at:

/Users/usernamehere/anaconda/envs/py2/lib/python2.7/site-packages/pandas/io/client_secrets.json

with information from the APIs Console <https://code.google.com/apis/console>.

Some extra details about the setup:

Upvotes: 0

Views: 1793

Answers (1)

measureallthethings
measureallthethings

Reputation: 1102

Looks like Google Developer Console used to provide default URI redirects, but not anymore.

When setting up client secrets, make sure to add the following to "Authorized redirect URIs":

http://localhost:8080/

This has to be exact--even a missing / will cause errors. One way to check this is to make sure the client_secrets.json file has this line:

"redirect_uris":["http://localhost:8080/"]

Upvotes: 1

Related Questions