我需要为我网站的不同用户做一些功能来自动将 html 文件上传到谷歌磁盘并打开它们以在谷歌文档中查看和编辑。为此,我创建了一个文档,将其传递到 google 磁盘并使用创建的文档的 id 在 google docs 中打开它。
为了访问 api,我使用了从服务 Google 帐户中获取的 json 文件。我试图以所有者和查看权限执行我的代码,但结果是一样的。
class CvView(AuthorizedMixin, View):
"""Here I check if the file format is html, I temporarily save it on disk and pass it to the file_to_drive function (to save it to google disk and open it in google docs) and delete it from disk"""
def get(self, request, employee_id, format_):
"""Returns employee's CV in format which is equal to `format_`
parameter."""
employee = …Run Code Online (Sandbox Code Playgroud) python django google-api google-drive-api google-api-python-client
BigQuery 的脚本/过程刚刚推出测试版 - 是否可以使用 BigQuery python 客户端调用过程?
我试过:
query = """CALL `myproject.dataset.procedure`()...."""
job = client.query(query, location="US",)
print(job.results())
print(job.ddl_operation_performed)
print(job._properties) but that didn't give me the result set from the procedure. Is it possible to get the results?
Run Code Online (Sandbox Code Playgroud)
谢谢你!
编辑 - 我正在调用的存储过程
CREATE OR REPLACE PROCEDURE `Project.Dataset.Table`(IN country STRING, IN accessDate DATE, IN accessId, OUT saleExists INT64)
BEGIN
IF EXISTS (SELECT 1 FROM dataset.table where purchaseCountry = country and purchaseDate=accessDate and customerId = accessId)
THEN
SET saleExists = (SELECT 1);
ELSE …Run Code Online (Sandbox Code Playgroud) 我正在扩展这个问题:How to create a job with Google Cloud Scheduler Python api
我想知道如何插入一个与函数一起传递的主体对象,我可以通过 来完成gcloud,并且根据 v1 文档,我知道主体需要在任何HttpTarget时候我尝试传递它它的方式错误并说:
TypeError: No positional arguments allowed
老实说,我根本没能去from google.cloud.scheduler_v1.types import HttpTarget as Target上班。
有人可以给我一个例子,他们成功地使用 API 在 Cloud Scheduler 中创建了一个作业,并发送了一个正文(JSON 对象)(当然是 POST 方法)?
cron python-3.x google-api-python-client google-cloud-platform google-cloud-scheduler
我尝试在 PC 上的自动运行中使用 python 上的 API。但我不能,因为每次程序启动时,它都会询问我有关授权码的信息。这是我的代码:
client_secret_file = "client_secret.json"
flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(
client_secrets_file, scopes)
credentials = flow.run_console()
youtube = googleapiclient.discovery.build(
api_service_name, api_version, credentials=credentials)
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?谢谢
python google-api youtube-api google-oauth google-api-python-client
我可以获取 mydrive 文件夹,但无法从 Google Drive API 访问共享云端硬盘文件夹。这是我的代码。(几乎与这里的指南代码相同)
我按照指南进行操作,完成“启用 Drive API”,在 VScode 上执行 pip 命令,并将凭据.json 放入工作目录。
(我没有收到错误,只得到了 mydrive 的文件名列表或代码打印的“未找到文件”。)
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/drive.metadata.readonly']
def main():
"""Shows basic usage of the Drive v3 API.
Prints the names and ids of the first 10 files the user has access to.
"""
creds = …Run Code Online (Sandbox Code Playgroud) python google-api google-drive-api google-api-python-client google-workspace
我有一个简单的Google App Engine应用程序,其中包含一个/update更新YouTube播放列表的页面.它看起来像这样:
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)
Run Code Online (Sandbox Code Playgroud)
它按预期update_playlist()工作,该方法完成其工作,但事实证明,在某些情况下,它可以运行很长一段时间,导致一个DeadlineExceededError.所以在阅读了可用的选项之后,我认为Task Queue API是要走的路(对吗?),我正在尝试使用它,遵循Python中的使用推送队列指南.
→简而言之,我分成UpdatePage了UpdatePageHandler+ UpdatePageWorker:
class UpdateHandlerPage(webapp2.RequestHandler):
@decorator.oauth_required
def get(self):
taskqueue.add(url='/updateworker')
class UpdateWorkerPage(webapp2.RequestHandler):
def post(self):
update_result = self.update_playlist()
...
routes = [('/update', UpdateHandlerPage),
('/updateworker', UpdateWorkerPage),
(decorator.callback_path, decorator.callback_handler())]
app = webapp2.WSGIApplication(routes, debug=True)
Run Code Online (Sandbox Code Playgroud)
不幸的是,在进行拆分后,我的OAuth2装饰器似乎不再起作用了:
INFO 2013-05-30 17:08:53,971 discovery.py:709] URL being requested: https://www.googleapis.com/youtube/v3/playlists?alt=json&part=snippet%2Cstatus
WARNING 2013-05-30 …Run Code Online (Sandbox Code Playgroud) python google-app-engine google-api task-queue google-api-python-client
我在我的python GAE应用程序上使用AppAssertionCredentials,作为服务帐户进行身份验证.但是,这是一个通用服务帐户,我不知道如何授权它在我的Google Apps域中模拟用户帐户.
这可以通过JWT凭证方式实现(请参阅此视频:http://www.youtube.com/watch?v = iK14bfd6qhs),但JWT不适用于appengine.
有什么建议?
python google-app-engine google-api google-api-python-client
我已经尝试使用 APIs explorer 和我自己的 python 代码,但似乎取消删除在 API 中不起作用。我在 Google Apps 管理控制台的“最近删除”用户列表中有一个帐户,但无论我在 API 资源管理器中做什么,它都不起作用。这是一个示例屏幕截图:


我相信它可能与 orgUnitPath 有关,但我不确定。我已经用'/'、'/myorg' 和'myorg' 试过了,但它们都不起作用。不太确定此时还可以尝试什么。
python google-apps google-api-python-client google-admin-sdk
该代码在SDK中运行得很好,但在Google AppEngine上,它会爆炸:
File "./oauth2client/util.py", line 137, in positional_wrapper
File "./googleapiclient/discovery.py", line 197, in build
File "./oauth2client/util.py", line 137, in positional_wrapper
File "./oauth2client/client.py", line 563, in new_request
File "./httplib2/__init__.py", line 1608, in request
File "./httplib2/__init__.py", line 1350, in _request
File "./httplib2/__init__.py", line 1306, in _conn_request
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/python_std_lib/httplib.py", line 1033, in getresponse
raise ResponseNotReady()
ResponseNotReady
Run Code Online (Sandbox Code Playgroud)
仅当GAE_USE_SOCKETS_HTTPLIB打开时才会发生这种情况.
File "./home/quickstart.py", line 2, in <module>
import httplib2
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 29, in <module>
import email
File "/home/sushant/home/email.py", line 7, in <module>
from apiclient import discovery
File "/usr/local/lib/python2.7/dist-packages/apiclient/__init__.py", line 19, in <module>
from googleapiclient import discovery
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py", line 41, in <module>
from email.generator import Generator as BytesGenerator
ImportError: No module named generator
Run Code Online (Sandbox Code Playgroud)
使用 google-api-python-client 并收到此错误。请帮忙 !!!
google-api ×7
python ×7
cron ×1
django ×1
google-apps ×1
google-oauth ×1
python-3.x ×1
task-queue ×1
youtube-api ×1