Closed
Description
Environment details
- OS: Darwin 18.5.0
- Python version: 2.7.14
- pip version: 9.0.3
google-api-python-client
version: 1.7.8
Steps to reproduce
- Am trying to hit the alerts app, but every endpoint I get has the following error:
<HttpError 400 when requesting https://alertcenter.googleapis.com/v1beta1/settings?alt=json returned "Request contains an invalid argument.">
<HttpError 400 when requesting https://alertcenter.googleapis.com/v1beta1/alerts?alt=json returned "Request contains an invalid argument.">
etc.
Code:
def create_google_alert_service(keyfile=None, scopes='https://www.googleapis.com/auth/apps.alerts'):
"""Convenience wrapper to create google drive API service."""
return create_google_api_service('alertcenter', 'v1beta1', scopes, keyfile)
def create_google_api_service(api, version, scopes, keyfile, http=None):
"""
Create a google api service using service account credentials.
"""
if keyfile is None:
raise('Error. You must specify a keyfile.')
credentials = ServiceAccountCredentials.from_json_keyfile_name(keyfile, scopes)
return build(api, version, credentials=credentials)
class AlertAPI(object):
"""Alert API object to test the alerts in the system."""
def __init__(self, page_size=None):
"""Init function for DriveAPI."""
self.pageSize = page_size or 100
self.alert_service = create_google_alert_service( secrets.get('google_alerts_keypath'))
def get_alerts(self):
alertId = 'XXXX'
try:
resp = self.alert_service.v1beta1().getSettings().execute()
resp = self.alert_service.alerts().feedback().list(alertId=alertId).execute()
resp = self.alert_service.alerts().get(alertId=alertId).execute()
resp = self.alert_service.alerts().list().execute()
except HttpError as e:
import pdb
pdb.set_trace()