google-api-python-client

Python FileNotFoundError: [Errno 2] No such file or directory

我只是一个虾纸丫 提交于 2020-01-07 02:13:06
问题 I have the following snippet from a script credentials = ServiceAccountCredentials.from_json_keyfile_name('tok.json', ['https://www.googleapis.com/auth/analytics.readonly']) This is for auth in google analytics But when I run the script on my site, the logs report the following error: FileNotFoundError: [Errno 2] No such file or directory: 'tok.json' I tried putting tok.json in all places (directories?) I can think of on the server, but the error does not disappear 回答1: I had this same error.

using /upload urls with Google API client

陌路散爱 提交于 2020-01-04 14:37:29
问题 Consider this: I am fetching rawbody messages by this call: service.users().messages().get(userId='me', format='raw', id=msgid) Then I am pushing rawbody messages by this Call: service.users().messages().insert(userId='me', body=message) Now when the mails contain attachments bigger 5MB, I encounter 413 "Request Entity Too Large.", and I can't push mails. GMail API messages.insert Documentation advices to use POST https://www.googleapis.com/upload/gmail/v1/users/userId/messages instead of

Empty Google Drive Trash with Python

折月煮酒 提交于 2020-01-04 14:07:04
问题 I am trying to empty my google drive trash bin with the API, but with no luck. I have tried using the requests library, and the script runs through without errors, but the drive trash is not deleted. I have been able to get files via the API, but not delete or empty the trash. Seems I should be able to just send an http request, but this is proving far more difficult for me than it seems it should be. Any advice would be greatly appreciated. Here is what I have. I am not even getting a json

How to authenticate with Google Spreadsheets API using Python client / discovery service?

空扰寡人 提交于 2020-01-03 04:25:41
问题 I'm using Python 2.7 and the client library for Google API which I am trying to use to get authenticated access to Spreadsheets like so: # sa == Service Account scope = 'https://spreadsheets.google.com/feeds' credentials = SignedJwtAssertionCredentials(sa_id, sa_key, scope) http = httplib2.Http() http = credentials.authorize(http) build('spreadsheets', 'v2', http=http) Note this is from a client script and not in Google App Engine. The output of the above is: File "/Library/Python/2.7/site

Google Contacts API - Accessing Other Users

一曲冷凌霜 提交于 2020-01-03 02:01:48
问题 I am trying to use the Google Contacts API and the Python / GDATA client handlers to access Contacts via OAuth 2.0 for users in the domain. I'm ultimately wanting to create a web service to add contacts for users, but the first step is getting this test working. I can access my own Contacts just fine if I use the default URI. However, when I pass in the email address to construct the URI for another user, I can't seem to access the other user's Contacts. Here is the code that I'm using:

Cloud Storage API requests from GAE - 403 Access not configured

做~自己de王妃 提交于 2020-01-01 16:51:24
问题 My GAE app is trying to manipulate files stored on Google Cloud Storage. The files are stored in the default bucket for my app. I already managed to read/write files to that bucket using the GCS Python Client Library (https://developers.google.com/appengine/docs/python/googlecloudstorageclient/). Unfortunately it does not support copy. Instead, I'm trying the JSON API with the API Client Library (https://google-api-client-libraries.appspot.com/documentation/storage/v1/python/latest/storage_v1

Unauthorized interaction with google calendar API v3

不想你离开。 提交于 2020-01-01 15:43:42
问题 I'm in the same situation as this guy (only that my problem is with python): I'm trying to retrieve data using a service account (using this example and after reading this blog entry since my application is a google app) but I get hit with a login required error and I cannot understand why. Let me represent it with a whole example: In [1]: import httplib2 In [2]: from apiclient.discovery import build In [3]: from oauth2client.client import SignedJwtAssertionCredentials In [4]: f = open(

Unauthorized interaction with google calendar API v3

喜欢而已 提交于 2020-01-01 15:43:34
问题 I'm in the same situation as this guy (only that my problem is with python): I'm trying to retrieve data using a service account (using this example and after reading this blog entry since my application is a google app) but I get hit with a login required error and I cannot understand why. Let me represent it with a whole example: In [1]: import httplib2 In [2]: from apiclient.discovery import build In [3]: from oauth2client.client import SignedJwtAssertionCredentials In [4]: f = open(

How do I rename a (work)sheet in a Google Sheets spreadsheet using the API in Python?

≡放荡痞女 提交于 2020-01-01 03:57:09
问题 I have been trying/looking to solve this problem for a long while. I have read the documentation for gspread and I cannot find that there is a way to rename a worksheet. Any of you know how to? I would massively appreciate it! There is indeed worksheet.title which gives the name of the worksheet, but I cannot find a way to rename the actual sheet. Thank you in advance! 回答1: This is an extraction of a library which I've coded personally: def _batch(self, requests): body = { 'requests':

Pandas GenericGBQException

老子叫甜甜 提交于 2019-12-31 05:43:12
问题 I'm trying to use try/except to query BigQuery tables, sometimes the query may not be correct in which case pandas raises a GenericGBQException error. My problem is I get name 'GenericGBQException' is not defined when trying to handle this error, example code below: try: df = pd.read_gbq(query, projID) query_fail = 0 except GenericGBQException: query_fail = 1 if query_fail == 1: do some stuff I can get by with catching all exceptions though obviously it's not ideal. 回答1: I suspect you want to