使用 Google Drive API (OAuth2) 获取文件夹中包含的所有文件的最佳方法是什么?
例如,使用 Dropbox,它只是对(1 个请求)的简单查询:
https://api.dropbox.com/1/metadata/dropbox/{folder}
对于 Skydrive,它是:
https://apis.live.net/v5.0/{folder}
然后查询upload_location(2个请求)。
根据 Google API 文档,对于 Google Drive,可以向
https://www.googleapis.com/drive/v2/files/{folder}/children
获取数据,以便data.items包含孩子的 ID。但是,使用此方法,如果文件夹中有n文件,则需要发出n+1请求(1 用于获取项目列表,n 用于每个项目)。
我认为n+1对这种基本任务提出要求太多了。这是 Google Drive API 的设计方式,还是有更快的方法来查询文件夹内的所有文件(具有足够的元数据)?
是否有用于地址自动完成的 Web API?
我正在使用Xamarin+MvvmCross框架解决方案开发跨平台移动应用程序,我需要一种方法来为用户提供地址自动完成功能。
最终目标是使用户能够开始键入地址并在视图中查看地址建议。
更喜欢使用谷歌地图,有谁知道我可以从用 C# 编写的共享代码项目中使用地址自动完成的方法吗?(请不要用 JavaScript 回答)。
其他想法也受到赞赏。
我们已经在应用程序中使用Google登录了。我们在请求登录时提供了serverClientID。
我们将user.serverAuthCode设置为nil。
我们的要求如下:
func googleLogin(){
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
let gid = GIDSignIn.sharedInstance()
if let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist") {
let myDict = NSDictionary(contentsOfFile: path)
gid?.serverClientID = "our servers cliet id as configured over firebase"
// This client id of our ios app we are getting from
// GoogleService-info.plist
gid?.clientID = myDict!.value(forKey: "CLIENT_ID") as! String
}
// gid?.serverClientID = "our_servers" // TODO: fetch from plist
gid?.scopes.append("https://www.googleapis.com/auth/gmail.readonly")
print("\nClient Id: \(gid!.clientID!) Server …Run Code Online (Sandbox Code Playgroud) <html>
<head>
<meta name="google-signin-scope" content="profile email">
<meta name="google-signin-client_id" content="MY_CLIENT_ID_ON_GOOGLE_DEV.apps.googleusercontent.com">
<!-- To integrate Google Sign-in -->
<script src="https://apis.google.com/js/api.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script>
</head>
<body>
<div class="g-signin2" data-onsuccess="onSignIn"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
不显示。这个HTML片段有什么问题?我还需要做其他事情才能显示Google登录按钮吗?
我正在使用Google One-Tap登录来对用户进行身份验证,并且在对用户进行身份验证后,我会获得访问令牌。我知道我可以使用此访问令牌来与JavaScript的Google API客户端(“ GAPI”)一起使用。但是我找不到使用此访问令牌的GAPI使用任何方法。
假设我已经有一个登录用户,是否可以使用GAPI?
我想要做的是简单地通过一次点击身份验证进行身份验证并对用户日历进行一次同意之后,访问用户日历。
google-api google-api-js-client gapi google-identity google-api-javascript-client
我正在使用Google People API来访问我的联系人。
我在Google Developers Console中激活了它,并创建了一个项目,一个服务帐户(以结尾....iam.gserviceaccount.com)和一个以JSON格式存储的身份验证密钥。
当我访问联系人时,似乎使用了我的服务帐户地址而不是我的Google帐户的联系人,从而导致列表为空。
如何告诉API使用我的帐户而不是服务帐户?
这是我到目前为止的代码:
from google.oauth2 import service_account
from googleapiclient.discovery import build
# pip install google-auth google-auth-httplib2 google-api-python-client
SCOPES = ['https://www.googleapis.com/auth/contacts.readonly']
KEY = '~/private.json'
credentials = service_account.Credentials.from_service_account_file(
KEY, scopes=SCOPES)
service = build(
serviceName='people', version='v1', credentials=credentials)
connections = service.people().connections().list(
resourceName='people/me', personFields='names').execute()
print(connections)
# result: {}
Run Code Online (Sandbox Code Playgroud) python google-api oauth-2.0 google-api-python-client google-people
我正在使用谷歌goecode API和一些邮政编码得到状态ZERO_RESULTS甚至'邮政编码存在(当搜索完整的地址,我可以找到它).
以下是我发送的请求(邮政编码:W1K6LX在英格兰):https://maps.googleapis.com/maps/api/geocode/json?component = postal_code:W1K6LX%7Ccountry:GB 因此,这给出了ZERO_RESULTS
但是当我搜索地址时:Kalrock 20 North Audley Street我可以在这里清楚地看到"London W1K 6LX":https://www.google.com/maps/place/Kalrock+Capital+Management/@51.5134013,-0.1556717 !,17Z /数据= 3M1 4B1 4M5 3M4 1s0x4876052eac174b5f:!!!!0xd76bd9d6e03653af8平方米3d51.513398 4D-0.153483
我在这里做错了吗?
我想从工作表中读取写入数据,读取工作正常,但写入却没有。我使用了文档中提到的所有范围:https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
data_writer(1,1,1)
Run Code Online (Sandbox Code Playgroud)
码:
from __future__ import print_function
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
# Setup the Sheets API
SCOPES = 'https://www.googleapis.com/auth/spreadsheets'+"https://www.googleapis.com/auth/drive.file"+"https://www.googleapis.com/auth/drive"
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = apiclient.discovery.build('sheets', 'v4', http=creds.authorize(Http()))
# Call the Sheets API
SPREADSHEET_ID = '1JwVOqtUCWBMm_O6esIb-9J4TgqAmMIdYm9sf5y-A7EM'
RANGE_NAME = 'Jokes!A:C'
# How the input data should be interpreted.
value_input_option = 'USER_ENTERED'
# How …Run Code Online (Sandbox Code Playgroud) python google-api google-oauth google-api-python-client anaconda
我正在编写一个python函数,该函数使用服务帐户凭据来调用Google cloudSQLAdmin api将数据库导出到存储桶。
已为服务帐户授予项目所有者权限,并且存储桶具有为项目所有者设置的权限。已为我们的项目启用sqlAdmin api。
Python代码:
from google.oauth2 import service_account
from googleapiclient.discovery import build
import googleapiclient
import json
def main():
SCOPES = ['https://www.googleapis.com/auth/sqlservice.admin', 'https://www.googleapis.com/auth/cloud-platform', 'https://www.googleapis.com/auth/devstorage.full_control']
SERVICE_ACCOUNT_FILE = './creds/service-account-credentials.json'
PROJECT = "[REDACTED]"
DB_INSTANCE = "[REDACTED]"
BUCKET_PATH = "gs://[REDACTED]/[REDACTED].sql"
DATABASES = [REDACTED]
BODY = { # Database instance export request.
"exportContext": { # Database instance export context. # Contains details about the export operation.
"kind": "sql#exportContext", # This is always sql#exportContext.
"fileType": "SQL", # The file type for the specified uri.
# …Run Code Online (Sandbox Code Playgroud) python google-api google-cloud-sql google-oauth google-cloud-platform
这些以下API的列表是否也已弃用?
https://www.googleapis.com/auth/userinfo.profile
https://www.googleapis.com/auth/contacts
https://www.googleapis.com/auth/contacts.readonly
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/profile.agerange.read
https://www.googleapis.com/auth/profile.language.read
https://www.googleapis.com/auth/user.addresses.read
https://www.googleapis.com/auth/user.birthday.read
google-api ×10
google-oauth ×5
python ×3
google-maps ×2
oauth ×2
anaconda ×1
autocomplete ×1
c# ×1
gapi ×1
gmail-api ×1
google-api-javascript-client ×1
google-plus ×1
html ×1
ios ×1
mvvmcross ×1
oauth-2.0 ×1
swift ×1