【问题标题】:What is the expiry policy of Google OAuth2 access tokens for Firebase database?Firebase 数据库的 Google OAuth2 访问令牌的到期政策是什么?
【发布时间】: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)

我的问题是 -

  1. 这些访问令牌的到期政策是什么?
  2. 我可以生成多少?
  3. 如何获取所有活动令牌并删除一个或多个?

【问题讨论】:

    标签: firebase firebase-realtime-database google-oauth google-api-python-client


    【解决方案1】:

    这些访问令牌的到期政策是什么?

    标准谷歌访问令牌持续一个小时。

    我可以生成多少?

    我认为没有限制

    如何获取所有活动令牌并删除一个或多个?

    你不能真正访问令牌没有存储它们包含访问权限。查找不记名令牌。

    这些问题都不重要

    您正在使用服务帐户。服务帐户是其客户端访问的不同类型的访问。只要您不删除服务帐户,它就不会过期。

    【讨论】:

    • 感谢您的回答!您能否告诉我更多有关未到期服务帐户的信息。我基本上想创建一个不会在一小时内过期的令牌。
    猜你喜欢
    • 2020-09-15
    • 2016-03-05
    • 2015-10-12
    • 1970-01-01
    • 2013-10-29
    • 2012-11-30
    • 2016-01-04
    • 2020-01-11
    • 2015-10-20
    相关资源
    最近更新 更多