Google API client_secrets 错误

Google API client_secrets error

我刚刚安装了 Anaconda(默认为 Python 3),因为我需要它来进行 pandas/accessing Google 分析。以下是有关通过 Python & pandas 访问 GA 的一些信息:http://pandas.pydata.org/pandas-docs/stable/remote_data.html#remote-data-ga

这里有人提出了类似的问题 Google API client secrets error (Python),但答案似乎对我的具体情况没有帮助。也就是说,我的错误是不同的;我已将 client_secrets.json 文件放在适当的目录中;该文件不为空,并且与开发者控制台中显示的内容完全相同。

这是代码和错误:

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>.

关于设置的一些额外细节:

看起来像 Google 开发者控制台曾经提供默认的 URI 重定向,但现在不再提供了。

设置客户端密码时,确保将以下内容添加到 "Authorized redirect URIs":

http://localhost:8080/

这必须是准确的——即使缺少 / 也会导致错误。检查这一点的一种方法是确保 client_secrets.json 文件有这一行:

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