google-api-python-client

Error trying to access “google drive” with python (google quickstart.py source code)

别说谁变了你拦得住时间么 提交于 2019-12-01 02:11:04
问题 I'm trying to learn how to access Google Drive from Python but I have problems. I followed the tutorial of google's official website: https://developers.google.com/drive/...t-python?hl=es In addition, i have seen the video tutorial about this, I think I do the same than the video guys exactly. I tell you the steps I've followed literally: 1 - Install pip tool to install the SDK from Google. 2 - Install the SDK from Google: "pip install --upgrade google-api-python-client" In this step all goes

How to make 'access_type=offline' / server-only OAuth2 operations on GAE/Python?

只愿长相守 提交于 2019-11-30 22:49:17
This post is a followup to How to do OAuth-requiring operations in a GAE cron job? , where I realized I'm mis-using the @oauth_required decorator from OAuth2DecoratorFromClientSecrets . As described by the OAuth 2.0 explained presentation, Oauth 2.0 solves the problem of: Building a service ... ... accessed by a user ... ... and accessing the user's data from a third party . That's what @oauth_required abstracts, and it does it well (currently my app "works": if I trigger the refresh page, I'm being asked to authorize access to my youtube data to my app, and the rest follows). But that's not

Got 403 error when connecting to Google Analytics with Python 2.7.x

☆樱花仙子☆ 提交于 2019-11-30 20:46:15
I tried to get data from Google Analytics API with Python client(google-api-python-client). Here's the code I used: from apiclient import discovery from oauth2client.client import SignedJwtAssertionCredentials from httplib2 import Http with open("ManagementGate-622edd43c0dd.p12") as f: private_key = f.read() credentials = SignedJwtAssertionCredentials( 'XXXXXXXX@developer.gserviceaccount.com', private_key, 'https://www.googleapis.com/auth/analytics.readonly') http_auth = credentials.authorize(Http()) service = discovery.build('analytics', 'v3', http=http_auth) result = service.data().ga().get(

How to make 'access_type=offline' / server-only OAuth2 operations on GAE/Python?

风流意气都作罢 提交于 2019-11-30 17:51:37
问题 This post is a followup to How to do OAuth-requiring operations in a GAE cron job? , where I realized I'm mis-using the @oauth_required decorator from OAuth2DecoratorFromClientSecrets . As described by the OAuth 2.0 explained presentation, Oauth 2.0 solves the problem of: Building a service ... ... accessed by a user ... ... and accessing the user's data from a third party . That's what @oauth_required abstracts, and it does it well (currently my app "works": if I trigger the refresh page, I

Google Sheets API “update” method Http Error 400

余生长醉 提交于 2019-11-30 15:08:13
I am trying to make a python script that reads and writes to a google spreadsheet. I've basically copied the python quickstart script at https://developers.google.com/sheets/quickstart/python and modified it using the reference at https://developers.google.com/resources/api-libraries/documentation/sheets/v4/python/latest/ . Everything works fine with the "get" method shown in the quickstart script. I can read the sheet with no errors. To use "update" instead of "get" (write to the sheet instead of read it), I removed the .readonly portion of the scope url. I also replaced the get() method with

How do you save a Google Sheets file as CSV from Python 3 (or 2)?

点点圈 提交于 2019-11-30 14:14:36
I am looking for a simple way to save a csv file originating from a published Google Sheets document? Since it's published, it's accessible through a direct link (modified on purpose in the example below). All my browsers will prompt me to save the csv file as soon as I launch the link. Neither: DOC_URL = 'https://docs.google.com/spreadsheet/ccc?key=0AoOWveO-dNo5dFNrWThhYmdYW9UT1lQQkE&output=csv' f = urllib.request.urlopen(DOC_URL) cont = f.read(SIZE) f.close() cont = str(cont, 'utf-8') print(cont) , nor: req = urllib.request.Request(DOC_URL) req.add_header('User-Agent', 'Mozilla/5.0 (Windows

Google Calendar API v3 - How to obtain a refresh token (Python)

筅森魡賤 提交于 2019-11-30 12:51:01
问题 I am trying to write a Django app which creates events in a specific Google calendar. So far I have been successful. There is only a little problem: I don't know how to obtain a refresh token with the google python client. The result is that after my token expires the app does not work and I have to create a new token. If I understand the documentation correct that's where the refresh token comes in. Access tokens have a limited lifetime and, in some cases, an application needs access to a

How to do OAuth-requiring operations in a GAE Task Queue?

邮差的信 提交于 2019-11-30 10:32:21
I have a simple Google App Engine app that includes a /update page which updates a YouTube playlist. It looks like this: class UpdatePage(webapp2.RequestHandler): @decorator.oauth_required def get(self): update_result = self.update_playlist() ... routes = [('/update', UpdatePage), (decorator.callback_path, decorator.callback_handler())] app = webapp2.WSGIApplication(routes, debug=True) It works as expected and the update_playlist() method does its job, but it turns out that under some circumstances it can run for a pretty long time, resulting in a DeadlineExceededError . So after reading about

Can't download video captions using youtube API v3 in python

旧巷老猫 提交于 2019-11-30 10:31:06
I am trying to download closed captions for this public youtube video (just for testing) https://www.youtube.com/watch?v=Txvud7wPbv4 I am using the code sample(captions.py) below that i got from this link https://developers.google.com/youtube/v3/docs/captions/download I have already stored the client-secrets.json(oauth2 authentification) and youtube-v3-api-captions.json in the same directory (asked in the sample code) I put this code line in cmd : python captions.py --videoid='Txvud7wPbv4' --action='download' I get this error: I don't know why it doesn't recognise the video id of this public

GAE enforcing sign in by app.yaml, python decorators or users.get_current_user?

*爱你&永不变心* 提交于 2019-11-30 07:43:25
I'm using 'login' option in my app.yaml configuration file for a GAE application. Looks like this: - url: /admin/.* script: myapp.app login: admin - url: /.* script: myapp.app login: required UPDATE (by suggestion of bossylobster ) : I want a user always signed in (unsigned users can't do anything), and I need to know who the user is. Actually, I need OAuth2 credentials to communicate with Google APIs (for example, I need to fetch some user's info with Google Profiles API, and write in the user's calendar with Google Calendar API). Finally, I need an admin user to perform some operations (like