google-api-python-client

Accessing folders, subfolders and subfiles using PyDrive (Python)

走远了吗. 提交于 2019-12-07 02:54:54
问题 I have the following code from the PyDrive documentation that allows access to top level folders in my Google Drive. I would like to access all of the folders, subfolders, and files from it. How would I go about doing this (I just started using PyDrive)? #!/usr/bin/python # -*- coding: utf-8 -*- from pydrive.auth import GoogleAuth from pydrive.drive import GoogleDrive gauth = GoogleAuth() gauth.LocalWebserverAuth() # Creates local webserver and auto handles authentication #Make GoogleDrive

Python can't find module 'clientsecrets' when trying to set up oauth2 in Django using the Google Python API

家住魔仙堡 提交于 2019-12-06 12:19:00
问题 I installed the Google APIs Client Library for Python on my Windows 7 box using pip . I am following the Django example that Google provides, but I can't start my server because Python throws an ImportError: No module named 'clientsecrets' . I have verified that clientsecrets.py is located in /path/to/python/Lib/site-packages . Any idea what could be causing this? I am using Python version 3.3.3 and Django version 1.6.1 回答1: I've changed in /usr/lib/python3/dist-packages/oauth2client/client

Move a sheet to a particular position using Python & the Google Sheets API

坚强是说给别人听的谎言 提交于 2019-12-06 09:56:46
I am trying to use the Google sheet API via python. So far I have been successful in performing some tasks. My problem is for example I have 4 sheets in a particular worksheet in the order of [sheet1][sheet2][sheet3][sheet4]. What I want is to manipulate the positions of the sheets. For example, sheet 4 would now be located at the second position. So now, the positions of the sheets would become [sheet1][sheet4][sheet2][sheet3] Is there a way to do this in python? Thanks! It should be definitely doable, because Google Sheets API supports this and the Google API Python Client is just a wrapper

How to use segments in Google Analytics API

微笑、不失礼 提交于 2019-12-06 07:25:20
In Google Analytics, we are able to create segments like below: From the Google Analytics API explorer , we can pull the segment information be it by segment id or by its code: I would assume we can just cut and paste that code into the google analytics core reporting v3 reference code like we do with all the other parameters: When I run the code however, I get this error: Arg, there was an API error : 400 : Invalid value 'users::condition::dateOfSession==2015-04-30;ga:sessionCount==1;condition::ga:campaign=@33100;sessions::condition::ga:userType=@Returning Visitor' for segment parameter. I am

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

别说谁变了你拦得住时间么 提交于 2019-12-06 06:48:30
问题 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"

User rate limit exceeded after a few requests

强颜欢笑 提交于 2019-12-06 03:44:20
问题 I am using Google Drive API through pydrive to move files between two google drive accounts. I have been testing with a folder with 16 files. My code always raises an error in the sixth file "User rate limit exceeded"> I know that there is a limit for the number of request (10/s or 1000/100s), but I have tried the exponential backoff suggested by the Google Drive API to handle this error. Even after 248s it still raises the same error. Here an example what I am doing def MoveToFolder(self

bq.py Not Paging Results

荒凉一梦 提交于 2019-12-06 03:38:42
问题 We're working on writing a wrapper for bq.py and are having some problems with result sets larger than 100k rows. It seems like in the past this has worked fine (we had related problems with Google BigQuery Incomplete Query Replies on Odd Attempts). Perhaps I'm not understanding the limits explained on the doc page? For instance: #!/bin/bash for i in `seq 99999 100002`; do bq query -q --nouse_cache --max_rows 99999999 "SELECT id, FROM [publicdata:samples.wikipedia] LIMIT $i" > $i.txt j=$(cat

Google API client secrets error (Python)

試著忘記壹切 提交于 2019-12-06 03:00:31
I want to retrieve data from Google analytics. I have created a service account in the console and I am using Google's Python ( hello_analytics_api_v3.py ) code to access the data. I have copied the client_secrets.json into my folder but get this error: *SystemExit: WARNING: Please configure OAuth 2.0 To make this sample run you will need to populate the client_secrets.json file found at:* What should I do? I am using Python 2.7. Ensure the terminal is pointing to the same path directory as your client_secrets.json file. i.e. type pwd in the console you're using to call the script and the

Google Oauth2.0 web application's “Authorized redirect URIs” must end with a public top-level domain (such as .com or .org)?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 22:51:11
问题 When create a Google API Oauth2.0 Credentials on Google Developers Console, I choose "Web Application" Application type. In the "Authorized redirect URIs" field, I can use http://127.0.0.1/callback, it work fine for me on local development. but when I want to use Google API Oauth2.0 Credentials on my server(let's say 99.99.99.99), I have to use http://99.99.99.99/callback as my "Authorized redirect URIs", but google give me a warning: Invalid Redirect: http://99.99.99.99/callback must end

GAE AttributeError: 'Credentials' object has no attribute 'with_subject'

◇◆丶佛笑我妖孽 提交于 2019-12-05 19:19:32
I have a python app I want to deploy on App Engine (2nd Generation Python 3.7) on which I use a Service Account with Domain-wide delegation enabled to access user data. Locally I do: import google.auth from apiclient.discovery import build creds, project = google.auth.default( scopes=['https://www.googleapis.com/auth/admin.directory.user', ], ) creds = creds.with_subject(GSUITE_ADMIN_USER) service = build('admin', 'directory_v1', credentials=creds) This works good and, as far as I know it is the current way to do this when using Application Default Credentials (locally I have GOOGLE