我正在尝试使用GoogleCredentials.get_application_default()在GAE中使用服务帐户凭据访问Google Ads API。
继续收到OAUTH_TOKEN_INVALID错误。
我的代码:
service_cred = GoogleCredentials.get_application_default()
service_ads_auth = GoogleServiceAccountClient(service_cred)
service_customer_service = service_ads_client.GetService('CustomerService')
print service_customer_service.getCustomers()
class GoogleServiceAccountClient(oauth2.GoogleOAuth2Client):
def __init__(self, service_credentials):
"""Initializes a GoogleServiceAccountClient."""
self.creds = service_credentials
def CreateHttpHeader(self):
self.creds.get_access_token()
oauth2_header = {}
self.creds.apply(oauth2_header)
return oauth2_header
我不知道为什么令牌无效?