【发布时间】:2019-07-11 01:38:50
【问题描述】:
我们一直在使用 google discovery api 进行分析设置来发出请求:“https://analytics.googleapis.com/$discovery/rest?version=v4” 这已经运行了两年多了,但是就在今天它开始响应:
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://analytics.googleapis.com/$discovery/rest?version=v4 returned "The request is missing a valid API key.">
我似乎在这个 api 上找不到任何状态,但我觉得好像有些事情可能发生了变化。
已执行手动测试,并且我一直在重复该问题。
>>> credentials = oauth2client.client.GoogleCredentials("<redacted>", "<redacted>", "<redacted>", "<redacted>", None, "https://accounts.google.com/o/oauth2/token", "UserAgentHere")
>>> credentials
<oauth2client.client.GoogleCredentials object at 0x7f533eaf60b8>
>>> import httplib2
>>> http = credentials.authorize(http=httplib2.Http())
>>> http
<httplib2.Http object at 0x7f533eaf6390>
>>> from apiclient.discovery import build
>>> build("analytics", "v4", http=http, cache_discovery=False)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/lib/python3.6/site-packages/googleapiclient/discovery.py", line 232, in build
raise e
File "/usr/lib/python3.6/site-packages/googleapiclient/discovery.py", line 224, in build
requested_url, discovery_http, cache_discovery, cache, developerKey)
File "/usr/lib/python3.6/site-packages/googleapiclient/discovery.py", line 277, in _retrieve_discovery_doc
raise HttpError(resp, content, uri=actual_url)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://analytics.googleapis.com/$discovery/rest?version=v4 returned "The request is missing a valid API key.">
>>>
【问题讨论】:
标签: google-analytics google-api google-analytics-api