google-api-python-client

PyDrive guath.Refresh() and Refresh Token Issues

Deadly 提交于 2019-12-05 12:59:46
Like others, I'm trying to get the Google refresh token to work in order to run scheduled tasks that copy and rename files. When I first manually authenticate within a terminal, my url ends in &access_type=offline. However, when I go in and try to manually use gauth.Refresh() in ipython, it fails with the same error as when my credentials file expires: pydrive.auth.RefreshError: No refresh_token found.Please set access_type of OAuth to offline. How do I actually set access_type to offline? Any suggestions are greatly appreciated. I have been here , here , and here trying to troubleshoot this.

How can I log in to an arbitrary user in appengine for use with the Drive SDK?

杀马特。学长 韩版系。学妹 提交于 2019-12-05 10:58:24
I have an application that needs to log into a singular Drive account and perform operations on the files automatically using a cron job. Initially, I tried to use the domain administrator login to do this, however I am unable to do any testing with the domain administrator as it seems that you cannot use the test server with a domain administrator account, which makes testing my application a bit impossible! As such, I started looking at storing arbitray oauth tokens--especially the refresh token--to log into this account automatically after the initial setup. However, all of the APIs and

Google Python Admin SDK using Oauth2 for a Service Account (Education Edition)-“oauth2client.client.AccessTokenRefreshError: access_denied” exception

╄→尐↘猪︶ㄣ 提交于 2019-12-05 10:03:58
I have been trying to get the Service Account authentication working for the Google Admin SDK for a few days now to no avail. I am using the google-api-python-client-1.2 library freshly installed from Google. I have been following Google's documentation on the topic. Links are here: htps://developers.google.com/accounts/docs/OAuth2ServiceAccount htps://developers.google.com/api-client-library/python/guide/aaa_oauth htp://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.client.SignedJwtAssertionCredentials-class.html And have the tasks.py Service Account example working which

No Google Drive files are listed in Drive API request

无人久伴 提交于 2019-12-05 09:34:53
I am trying to get a list of the files in my Google Drive using a desktop app. The code is as follows: def main(argv): storage = Storage('drive.dat') credentials = storage.get() if credentials is None or credentials.invalid: credentials = run(FLOW, storage) # Create an httplib2.Http object to handle our HTTP requests and authorize it # with our good Credentials. http = httplib2.Http() http = credentials.authorize(http) service = build("drive", "v2", http=http) retrieve_all_files(service) Then in retrieve_all_files, I print the files: param = {} if page_token: param['pageToken'] = page_token

google.appengine.ext Python Module ImportError No module named google.appengine.ext

半腔热情 提交于 2019-12-05 06:50:33
Python 2.7.6, Google APIs Client Library for Python for Google App Engine, Google Developer's Guide I'm going through the Google documentation, and trying to duplicate their example. When I run the command: from google.appengine.ext import webapp from Python Shell, I get the error msg: No module named google.appengine.ext So obviously, that file is not on my computer. I've done searches for the file on my hard drive and haven't found anything. I've run easy_install to install the Google API as instructed in the official Google Quick Start video. I'm not sure if Google's documentation is now

How to download files from Google Vault export immediately after creating it with Python API?

大城市里の小女人 提交于 2019-12-05 00:50:18
问题 Using Python API, I have created an export. How do I download the .zip file in the export using the same authorized service? When creating the export, I can see the bucketName and objectNames of the cloudStorageSink, however I cannot find any documentation on how to download them to my host using the existing service that created the export #!/usr/bin/env python from __future__ import print_function import datetime import json import time from googleapiclient.discovery import build from

Create a folder (if not exists) on google drive and upload a file to it using Python script

只愿长相守 提交于 2019-12-04 21:36:40
问题 So far I can upload file to the folder if it exists. I can't figure out a way to create one though. So if the folder does not exist, my script dies. import sys from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gpath = '2015' fname = 'Open Drive Replacements 06_01_2015.xls' gauth = GoogleAuth() gauth.LocalWebserverAuth() drive = GoogleDrive(gauth) file_list = drive.ListFile({'q': "'root' in parents and trashed=false"}).GetList() for file1 in file_list: if file1['title']

Google AppEngine to Fusion Tables with Service Accounts

别等时光非礼了梦想. 提交于 2019-12-04 17:56:35
Late to the game on migrating to the /v1 Fusion Table API but no holding off any longer. I'm using Python on AppEngine and trying to connect to Google Fusion Tables with Google Service Accounts (the more complicated cousin of OAuth2 for server side apps that uses JSON Web Tokens) I found another question that pointed me to some documentation for using Service Accounts with Google Prediction API. Fusion Table and Google Service Accounts So far I've got import httplib2 from oauth2client.appengine import AppAssertionCredentials from apiclient.discovery import build credentials =

OAuth2 authentication in GAE accessing Calendar API V3 (domain hosted)

落花浮王杯 提交于 2019-12-04 14:52:02
I'm developing a Google App Engine app with Python. And I'm using: Google Calendar API v3 (to access a calendar in my own domain. So, this is Google Apps installed in my domain) Google APIs client library for Python. OAuth2 to authenticate users of my domain (name@mydomain.com) I thought I had to use Service Accounts, because of this: "If your App Engine application needs to call an API to access data owned by the application's project, you can simplify OAuth 2.0 by using Service Accounts" Taken from https://developers.google.com/api-client-library/python/platforms/google_app_engine

Unauthorized interaction with google calendar API v3

半世苍凉 提交于 2019-12-04 14:46:00
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('abd45679ffg32343-privatekey.p12', 'rb') In [5]: key = f.read() In [6]: f.close() In [7]: credentials =