google-api-python-client version: 1.7.11Sorry, I cannot share the whole code, but the main idea is:
from apiclient import discovery
creds = OAuth2Credentials(...)
http = creds.authorize(http = httplib2.Http())
service = discovery.build('dfareporting', 'v3.3', http=http)
service.files().get_media(...).execute()
I'm getting this error:
W0813 19:40:45.663586 1 http.py:118] Invalid JSON content from response: b"<?xml version='1.0' encoding='UTF-8'?><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your Google secret key and signing method.</Message><StringToSign>GET\n\n\n1565725545\nx-goog-api-client:gdcl/1.7.11 gl-python/3.7.4\n/...</StringToSign></Error>"
I've tested the same code with version 1.7.10, and it works. I think this may be a regression introduced here, but I'm not sure: https://github.com/googleapis/google-api-python-client/pull/734
cc @busunkim96 @tseaver @dazuma
@asiunov Is it possible to know which service you're using?
service = discovery.build('...', 'v3.3', http=http)
dfareporting
just in case someone needs a workaround, try to downgrade the lib:
pip3 uninstall google-api-python-client
pip3 install google-api-python-client==1.7.10
I tested a .get_media on the Drive API, as I don't have Campaign Manager set up.
I uploaded a .txt to Drive and downloaded it. I did not see the error above. :thinking: There may be something different about the DFA Reporting API. I will do some more investigation and get back to you.
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/drive']
def main():
"""Shows basic usage of the Drive v3 API.
Prints the names and ids of the first 10 files the user has access to.
"""
creds = None
# The file token.pickle stores the user's access and refresh tokens, and is
# created automatically when the authorization flow completes for the first
# time.
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
# If there are no (valid) credentials available, let the user log in.
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
'credentials.json', SCOPES)
creds = flow.run_local_server(port=8080)
# Save the credentials for the next run
with open('token.pickle', 'wb') as token:
pickle.dump(creds, token)
service = build('drive', 'v3', credentials=creds)
# Call the Drive v3 API
results = service.files().list(
pageSize=10, fields="nextPageToken, files(id, name)").execute()
items = results.get('files', [])
if not items:
print('No files found.')
else:
print('Files:')
for item in items:
print(u'{0} ({1})'.format(item['name'], item['id']))
# Download a file
id = "FILE_ID_XXXXX"
obj = service.files().get_media(fileId=id).execute()
print(obj)
if __name__ == '__main__':
main()
The DFA Reporting backend cannot correctly process requests sent with the X-Goog-Api-Client header. Internal Issue 127940526
As a workaround, please use continue to use the previous library version.
google-api-python-client==1.7.10
Thanks for reporting this @asiunov!
@busunkim96 馃憤
Thank you!
Fix has been deployed on the backend.
This is still not working with google-api-python-client==1.8.
API service dfareporting
API version v3.4
@btx Would you mind opening a new issue? Repository maintainers are better able to track new issues than replies to closed issues.
Are you seeing the same error or a different one?