【发布时间】:2022-01-17 13:04:04
【问题描述】:
我正在验证对 Firebase 实时数据库的 REST API 调用,并决定使用 Google OAuth2 访问令牌来授权请求。我已经关注了这个文档- https://firebase.google.com/docs/database/rest/auth
并使用此代码生成新的访问令牌
from google.oauth2 import service_account
# Define the required scopes
scopes = [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/firebase.database"
]
# Authenticate a credential with the service account
credentials = service_account.Credentials.from_service_account_file(
"path/to/serviceAccountKey.json", scopes=scopes)
# Or, use the token directly, as described in the "Authenticate with an
# access token" section below. (not recommended)
request = google.auth.transport.requests.Request()
credentials.refresh(request)
access_token = credentials.token
print(access_token)
我的问题是 -
- 这些访问令牌的到期政策是什么?
- 我可以生成多少?
- 如何获取所有活动令牌并删除一个或多个?
【问题讨论】:
标签: firebase firebase-realtime-database google-oauth google-api-python-client