google-api-python-client

How to avoid 'Failed to retrieve access token: { “error” : “invalid_grant” }' in offline GAE cron tasks?

妖精的绣舞 提交于 2019-11-30 05:26:15
This post is a followup to How to make 'access_type=offline' / server-only OAuth2 operations on GAE/Python . The http = credentials.authorize(httplib2.Http()) part no longer fails when testing, but it seems it still does when run by GAE's cron, where it's unable to refresh my access_token : I can manually run my job by calling /fetch , say at 11:45. Scheduling immediately a /cronfetch job at 11:55 works then , without any access_token issue. But then, I woke up this morning seeing that the same /cronfetch task (same except the timing, which is at 01:00 for my non-test daily task) failed: I

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

你离开我真会死。 提交于 2019-11-30 04:58:00
问题 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

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

痞子三分冷 提交于 2019-11-30 03:17:41
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 Google API beyond the lifetime of a single access token. When this is the case, your application can

How do I use google.auth instead of oauth2client in Python to get access to my Google Calendar

余生颓废 提交于 2019-11-29 22:07:39
问题 Several years ago I created a small Python program which were able to maintain my calendar using oauth2client which is now deprecated and replaced with google.auth - but I cannot find any useful documentation and my program stopped working complaining about a _module KeyError which nobody appear to have solved except by upgrading. I cannot figure out how to replace the oauth2client with google.auth: import datetime import httplib2 import os from apiclient import discovery import oauth2client

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

狂风中的少年 提交于 2019-11-29 16:21:59
问题 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' -

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

半城伤御伤魂 提交于 2019-11-29 10:25:15
问题 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

How to avoid 'Failed to retrieve access token: { “error” : “invalid_grant” }' in offline GAE cron tasks?

和自甴很熟 提交于 2019-11-29 03:53:56
问题 This post is a followup to How to make 'access_type=offline' / server-only OAuth2 operations on GAE/Python. The http = credentials.authorize(httplib2.Http()) part no longer fails when testing, but it seems it still does when run by GAE's cron, where it's unable to refresh my access_token : I can manually run my job by calling /fetch , say at 11:45. Scheduling immediately a /cronfetch job at 11:55 works then , without any access_token issue. But then, I woke up this morning seeing that the

Google contacts import using oauth2.0

萝らか妹 提交于 2019-11-28 19:53:06
What possible ways to import google contacts using python and oauth2.0 exists? We successfully got credentials, and our application requests access to contacts, but after getting credentials I can't find way to discover contacts api. So things like: from apiclient.discover import build import httplib2 http = httplib2.Http() #Authorization service = build("contacts", "v3", http=http) Gives us UnknownApiNameOrVersion exception. It looks like Contacts API not in list of supported APIs for apiclient. I'm looking for alternative ways. bossylobster The Google Contacts API can't be used with the

Google Drive Python API resumable upload error 401 after 2 hours

落花浮王杯 提交于 2019-11-28 02:00:50
First of all, I'm sorry if this is a too silly question... this is the first time I'm trying to use any of the technologies involved in this script (Python, the drive api, oauth 2.0, etc). I swear I've been searching and trying this for about a week before posting the question. hehehe I'm trying to use the google-api-python-client to upload a big file (3.5GiB) that is on a terminal only Linux Debian. I've had some success uploading small files, but when I try to upload the big file, the upload stops about 1~2 hours after it started with HTTP 401 error (unauthorized). I've been looking on how

HTTPException: Deadline exceeded while waiting for HTTP response from URL: #deadline

浪子不回头ぞ 提交于 2019-11-27 16:01:19
问题 We are using the developers python guide with Python data 2.15 library and as per example stated for app engine. createSite("test site one", description="test site one", source_site =("https://sites.google.com/feeds/site/googleappsforus.com/google-site-template" )) We are getting an un-predictable response every time we use. Exception: HTTPException: Deadline exceeded while waiting for HTTP response from URL: https://sites.google.com/feeds/site/googleappsforyou.com Did someone experience the