我在使用 Google Drive API 上传文件时遇到了一些问题。API 不会返回任何错误并显示文件已成功上传。但是,当我尝试检索文件列表时,它不会出现,当我尝试查看 Google Drive API 页面时也不会出现。
以下是一些观察结果:
这是我的代码的外观(我尝试根据 Java 代码段创建它)。
public class Quickstart {
/** Application name. */
private static final String APPLICATION_NAME = "Drive API Java Quickstart";
/** Directory to store user credentials for this application. */
/** Global instance of the JSON factory. */
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
/** Global instance of the HTTP transport. …Run Code Online (Sandbox Code Playgroud) 在 Google 为其 API 提供的各种 javascript 示例(例如此处)中,他们使用以下代码从 html 加载脚本:
<script async defer src="https://apis.google.com/js/api.js"
onload="this.onload=function(){};handleClientLoad()"
onreadystatechange="if (this.readyState === 'complete') this.onload()">
</script>
Run Code Online (Sandbox Code Playgroud)
我的理解是async/defer告诉浏览器什么时候加载和执行脚本并且彼此有些矛盾。我有几个问题:
async和是什么意思defer?onload事件中,为什么他们function(){};在调用之前先为事件分配一个空函数 ( ) handleClientLoad()?谢谢。
有没有办法在 Google Maps API 上批量处理多个反向地理编码请求?
我只看到可能的简单请求:https : //maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY
我试图用 API 清空我的谷歌驱动器垃圾箱,但没有运气。我曾尝试使用请求库,脚本运行没有错误,但驱动器垃圾没有被删除。我已经能够通过 API 获取文件,但不能删除或清空垃圾箱。似乎我应该能够只发送一个 http 请求,但这对我来说比看起来要困难得多。任何建议将不胜感激。这是我所拥有的。我什至没有收到 json 响应。
from __future__ import print_function
import httplib2
import os
import requests
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None
SCOPES = 'https://www.googleapis.com/auth/drive'
CLIENT_SECRET_FILE = 'C:\Scripts\Link Expiration\client_secret.json'
APPLICATION_NAME = 'Drive API Delete Trash'
def get_credentials():
"""Gets valid user credentials from storage.
If nothing has been stored, or if the stored credentials are invalid,
the …Run Code Online (Sandbox Code Playgroud) 我想弄清楚是否可以通过 Firebase 将事件添加到用户的谷歌日历服务器端。
我已经阅读了这个和这个,这似乎是我想要实现的目标,但它解释了我想向他们的日历添加事件的用户应该与我为我的应用程序创建的帐户共享他们的日历。
这是真的还是我误解了什么?
如果有任何关于 JavaScript/NodeJS 的指南,我也很感激。
google-calendar-api google-api firebase google-cloud-functions
Flutter,谷歌日历 API v3 https://pub.dartlang.org/packages/googleapis
作品:
Future<List<Event>> getEvents() =>
calendarApi.events.list("primary",
)
.then((Events events){
return events.items;
}).catchError((e){
print("error encountered");
print("${e.toString()}");
});
Run Code Online (Sandbox Code Playgroud)
不起作用:
DateTime start = new DateTime.now().subtract(new Duration(days: 10));
DateTime end = new DateTime.now().add(new Duration(days: 10));
..
Future<List<Event>> getEvents() =>
calendarApi.events.list("primary",
timeMin: start,
timeMax: end,
)
.then((Events events){
return events.items;
}).catchError((e){
print("error encountered");
print("${e.toString()}");
});
Run Code Online (Sandbox Code Playgroud)
以下是使用 httplib2 库访问谷歌存储桶的代码
import json
from httplib2 import Http
from oauth2client.client import SignedJwtAssertionCredentials
from googleapiclient.discovery import build
from pprint import pprint
client_email = 'my.iam.gserviceaccount.com'
json_file = 'services.json'
cloud_storage_bucket = 'my_bucket'
files = 'reviews/reviews_myapp_201603.csv'
private_key = json.loads(open(json_file).read())['private_key']
credentials = SignedJwtAssertionCredentials(client_email,
private_key,'https://www.googleapis.com/auth/devstorage.read_only')
storage = build('storage', 'v1', http=credentials.authorize(Http()))
pprint(storage.objects().get(bucket=cloud_storage_bucket, object=files).execute())
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我是否可以使用 Python Requests 库发出 http 请求吗?如果是,如何?
python google-api oauth-2.0 python-requests google-api-python-client
我是一名拥有近 300 名用户的 GSuite 管理员,我正在从 GSuite 迁移。我需要下载他们创建/上传的所有用户文件。
我从编写一个 Python 脚本开始,该脚本将在列表中向我显示用户文件,并且似乎我遇到了压倒性的授权问题。
https://www.googleapis.com/auth/drive,https://www.googleapis.com/auth/admin.datatransfer,https://www.googleapis.com/auth/admin.directory.user, https://www.googleapis.com/auth/admin.directory.group根据文档(https://developers.google.com/admin-sdk/directory/v1/guides/delegation)非常好
我正在从 ServiceAccountCredentials 创建一个资源对象,并分别基于 API 名称/版本“drive”和“v3”构建一个对象,并尝试根据 Google 的快速入门(https://developers.google.com/drive)获取文件列表/api/v3/quickstart/python):
from googleapiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
SERVICE_ACCOUNT_EMAIL = "drive-getter@mygoogledomain.iam.gserviceaccount.com"
SERVICE_ACCOUNT_PKCS12 = "./service_key.json"
def create_directory_service(user_email):
credentials = ServiceAccountCredentials.from_json_keyfile_name(SERVICE_ACCOUNT_PKCS12, scopes=['https://www.googleapis.com/auth/drive'])
credentials = credentials.create_delegated(user_email)
return build('drive', 'v3', credentials=credentials)
resource = create_directory_service('username@mydomain.com')
results = resource.files().list(
pageSize=10, fields="nextPageToken, files(id, name)"
).execute()
items = …Run Code Online (Sandbox Code Playgroud)我正在构建一个 AWS Lambda 函数,该函数使用 Node.js 从 Google Calendar API 中提取信息。然后 Node 应用程序向第三方应用程序发送一个 html 响应。我基本上遵循google 的本指南,除了我将 html 发送到其他地方进行渲染。我一直遇到一个错误,Google 告诉我我没有将来自 Lambda 的 javascript 来源列入白名单。这是错误文本:
{error: "idpiframe_initialization_failed", details: ""Not a valid origin for the client: https://<Lambda URL>.execute-api.us-west-2.amazonaws.com has not been whitelisted for client ID <My_Google_API_Client_Id>.apps.googleusercontent.com. Please go to https://console.developers.google.com/ and whitelist this origin for your project's client ID."}
我已经进入 Google API 开发人员控制台并将该 URL 列入白名单,但我仍然收到该错误。这是一个屏幕截图。
我也试过将“us-west-2.amazonaws.com”列入白名单,但没有成功。谢谢!!
google-calendar-api google-api amazon-web-services node.js aws-lambda
我们正在尝试将服务帐户身份验证与我们的后端服务结合使用,以使用 Google Cloud Storage JSON API。但无法确切地找出应该如何完成。我们找到了与 Client Libs 一起使用的示例,但我们正在使用 REST API。有人可以向我解释如何在 POSTMAN 中设置服务帐户身份验证吗?
google-api ×10
python ×3
aws-lambda ×1
events ×1
firebase ×1
flutter ×1
google-maps ×1
google-oauth ×1
ios ×1
java ×1
javascript ×1
node.js ×1
oauth ×1
oauth-2.0 ×1