我正在使用“ https://developers.google.com/identity/sign-in/ios/backend-auth ”进行编码
令牌是
eyJhbGciOiJSUzI1NiIsImtpZCI6IjI2ZmM0Y2QyM2QzODdjYmM0OTBmNjBkYjU0YTk0YTZkZDE2NTM5OTgiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiIzMjAzMTg3OTI4MTQtcXBnZ2ZscGYxNWhpN3NrbDUzbzR2aXA5cTdhb2QzOWYuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJhdWQiOiIzMjAzMTg3OTI4MTQtcXBnZ2ZscGYxNWhpN3NrbDUzbzR2aXA5cTdhb2QzOWYuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDQwODQzNzYwMjYyNzczNTA0MDgiLCJlbWFpbCI6InVzNDAyNzY5NDExQDE2My5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXRfaGFzaCI6InlicUhLQlRPVVM5ZWJwS3FHVmZmcFEiLCJpYXQiOjE1NTYxODI0MTksImV4cCI6MTU1NjE4NjAxOX0.ABE-rltHIdEfxHwVHXMpcwg1HdoKarrGEcj2gqRAtegDpjelxdqnQslcA4V7nm_mZx_eqkw54FiWeDJ0Rif39kf-hUuBMJdjD4qOzKLqUbyjLgYTy0qi5zZ4vav95K6Y-LeOGTLOGWNiak9t1a3D1y9Xvub24r0t7dU9chqAp7aZnqW_995si_6oJwlPOQCMkfmhkUm9xeYyAWNRsJN6W2rUN41oFUN8KAboUhyjgQFnOdu85KzeDbll_m-HaFYEHh5FdzUnpgt79wKNtFXPnq000EYtHa4AvhtV9MoidMQCx0g02f1PEw4VvAGsQT6MN6Z4cJH-kGl8LHxZA1dslQ
Run Code Online (Sandbox Code Playgroud)
我可以从https://oauth2.googleapis.com/tokeninfo?id_token=TOKEN获取数据

但是当我使用 Google API Client Library 时,我发现id_token.verify_oauth2_token获取结果太慢了。为什么?我的代码超出了:
from google.oauth2 import id_token
from google.auth.transport import requests
GOOGLE_CLIENT_ID = '320318792814-qpggflpf15hi7skl53o4vip9q7aod39f.apps.googleusercontent.com'
def auth_google(token):
CLIENT_ID = GOOGLE_CLIENT_ID
try:
# Specify the CLIENT_ID of the app that accesses the backend:
idinfo = id_token.verify_oauth2_token(token, requests.Request(), CLIENT_ID)
print idinfo
# Or, if multiple clients access the backend server:
# idinfo = id_token.verify_oauth2_token(token, requests.Request())
# if idinfo['aud'] not in [CLIENT_ID_1, CLIENT_ID_2, CLIENT_ID_3]:
# raise ValueError('Could not verify audience.')
if idinfo['iss'] …Run Code Online (Sandbox Code Playgroud) spreadsheets.batchUpdate类似 和的调用spreadsheets.values.batchUpdate可以在一次调用中执行多个更新操作。
我在https://developers.google.com/sheets/api/limits上阅读了有关 google Sheets api 使用限制的信息,但是尚不清楚这些调用是否算作一个或多个请求。你能解释一下吗?
谢谢
我正在开发一个应用程序,将获取的值保存到谷歌电子表格中。我想知道在使用 python 时是否可以通过 google-spreadsheet API 执行以下操作
namename通过或请求时获取电子表格列表id提前致谢!
python google-sheets google-api-python-client google-sheets-api
我正在尝试从我的谷歌驱动器下载电子表格。我正在关注此参考文献,但在许可方面遇到问题。我从https://www.googleapis.com/auth/drive.file开始并得到了这个
"Insufficient Permission: Request had insufficient authentication scopes."
Run Code Online (Sandbox Code Playgroud)
通读权限文档后,您会看到https://www.googleapis.com/auth/drive的以下内容。
访问所有用户文件的完整、许可范围,不包括应用程序数据文件夹。
但即使使用这个范围我仍然收到相同的错误消息。
我的代码是这样的
"Insufficient Permission: Request had insufficient authentication scopes."
Run Code Online (Sandbox Code Playgroud) python google-api google-drive-api google-oauth google-api-python-client
I want to create a simple script which will upload a file to my Drive every 5 minutes using cronjob. This is the code I have so far using the boilerplate code I extracted from different locations (mainly 2: getting started page & create page):
from __future__ import print_function
from apiclient import errors
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.http import MediaFileUpload
def activateService():
creds = None
if os.path.exists('token.pickle'): …Run Code Online (Sandbox Code Playgroud) 我使用 Document OCR API 从 pdf 文件中提取文本,但部分内容不准确。我发现原因可能是因为一些汉字的存在。
以下是我虚构的示例,其中我裁剪了提取文本错误的部分区域,并添加了一些汉字来重现该问题。

当我使用网站版本时,我无法获取汉字,但其余字符是正确的。

当我使用Python提取文本时,我可以正确地获取汉字,但剩余的部分字符是错误的。

我得到的实际字符串。

网站和API中的Document AI版本是否不同?如何正确获取所有字符?
更新:
当我在打印文本后打印detected_languages(不知道为什么 for lines = page.lines,detected_languagesfor 两行都是空列表,需要更改为page.blocks或page.paragraphs首先)时,我得到以下输出。

代码:
from google.cloud import documentai_v1beta3 as documentai
project_id= 'secret-medium-xxxxxx'
location = 'us' # Format is 'us' or 'eu'
processor_id = 'abcdefg123456' # Create processor in Cloud Console
opts = {}
if location == "eu":
opts = {"api_endpoint": "eu-documentai.googleapis.com"}
client = documentai.DocumentProcessorServiceClient(client_options=opts)
def get_text(doc_element: dict, document: dict):
"""
Document AI …Run Code Online (Sandbox Code Playgroud) python ocr google-api-python-client google-cloud-platform cloud-document-ai
我正在尝试使用 python 打开私人谷歌工作表。这里的最终目标是将私有工作表数据读入 json 对象。我已确保创建一个谷歌云项目,启用 API 和服务帐户。服务帐户电子邮件已共享并添加为编辑者。我还为桌面应用程序创建了 OAuth 密钥。这是必需的,因为该文件是私有的。
我知道我需要以某种方式请求一个令牌来访问工作表 API,但我不知道如何创建请求并利用client_secret从 OAuth 密钥生成的文件。我认为 googleAPI 会有一个可以直接传递此文件的函数,但我迷失在文档中。
任何见解将不胜感激!
python google-api google-api-python-client service-accounts google-sheets-api
有没有办法获得 Google Sheet API 的永久 oauth2 令牌或半永久令牌?
我现在使用的那个每 7 天就会过期一次,这不是很有帮助。
如果没有,是否有可以与 python 连接的在线电子表格应用程序的替代方案?
google-api google-sheets google-oauth google-api-python-client google-sheets-api
我想在我的 Django 应用程序中使用 Google Calendar API。我已按照此处的说明进行操作:https://karenapp.io/articles/how-to-automate-google-calendar-with-python-using-the-calendar-api/
我还在 Google API 中添加了重定向 uri - 似乎浏览器试图在服务器端打开(就像在本地一样,但我无法操作它,因为服务器端的浏览器没有显示)。在终端中,我确实看到“请访问此 URL 来授权此应用程序:https://accounts.google.com/...”
关于我能做什么有什么想法吗?
views.py 中的代码:
import datetime
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
SCOPES = ['https://www.googleapis.com/auth/calendar']
CREDENTIALS_FILE = 'path_to_file/credentials.json'
def get_calendar_service():
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
CREDENTIALS_FILE, SCOPES)
creds = …Run Code Online (Sandbox Code Playgroud) python django google-calendar-api heroku google-api-python-client
我正在尝试创建一个谷歌凭证对象来访问谷歌驱动器。我将令牌和用户数据存储在会话中,因此我尝试创建该对象而不从credentials.json 文件加载它们。当用户首次登录 Web 应用程序并将令牌存储在用户会话中时,我正在处理身份验证,该会话的超时时间为 24 小时,与默认访问令牌相同,因此 24 小时后,要求用户再次登录因此,将创建一个具有有效访问令牌的新会话。所以我的想法是复用access token来限制登录量,提高用户体验。
这是关于我如何尝试创建 google 凭证对象的一小段代码
from oauth2client.client import GoogleCredentials
access_token = request.session['access_token']
gCreds = GoogleCredentials(
access_token,
os.getenv('GOOGLE_CLIENT_ID'),
os.getenv('GOOGLE_CLIENT_SECRET'),
refresh_token=None,
token_expiry=None,
token_uri=GOOGLE_TOKEN_URI,
user_agent='Python client library',
revoke_uri=None)
build('drive', 'v3', credentials = gCred)
Run Code Online (Sandbox Code Playgroud)
每当我尝试运行此代码时,都会收到以下错误:
Insufficient Permission: Request had insufficient authentication scopes.". Details: "[{'domain': 'global', 'reason': 'insufficientPermissions', 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}]"
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "dailyLimitExceededUnreg",
"message": "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.",
"extendedHelp": …Run Code Online (Sandbox Code Playgroud) python oauth-2.0 google-drive-api google-oauth google-api-python-client