发生Google Anlytics API身份验证错误

时间:2019-01-14 20:48:19

标签: python google-analytics oauth-2.0 google-analytics-api google-analytics-v4

从上周五开始,我收到了来自Google Analytics(分析)V4 API的间歇性身份验证错误。错误消息:

HttpAccessTokenRefreshError: invalid_grant: Invalid issuer: Not a service account.

无法真正找出导致间歇性错误的原因。任何帮助表示赞赏。

from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
import httplib2


service_email = "abc.apps.googleusercontent.com"
scopes = ['https://www.googleapis.com/auth/analytics.readonly']
url = ('https://analyticsreporting.googleapis.com/$discovery/rest')
pem_file_path = 'abc.pem'

credentials = ServiceAccountCredentials.from_p12_keyfile(service_email, 
pem_file_path, scopes=scopes)
http = credentials.authorize(httplib2.Http())
service = build('analytics', 'v4', http=http, discoveryServiceUrl=url )

0 个答案:

没有答案