简体   繁体   English

在云功能 (firebase) 上存储 3dparty auth 访问密钥

[英]Storing 3dparty auth access key on cloud functions (firebase)

I am planing a project with cloud function my functions should connect a 3d party api using authentication header...etc我正在计划一个云项目 function 我的功能应该连接一个 3d 方 api 使用身份验证 header...等

this 3dapi requests to refresh the access every hour so i think about creating a cloud task in separate project that will keep the token.这个 3dapi 请求每小时刷新一次访问权限,所以我考虑在单独的项目中创建一个云任务来保留令牌。 and in my functions i will be able to get it somehow在我的职能中,我将能够以某种方式获得它

my question is how can i do that我的问题是我该怎么做

so i would like a 2 projects: 1 for keeping access tokens on firestore or on somewhere else 2- the functions app will be retrieve them when it want in order to make it secured所以我想要一个 2 个项目:1 用于将访问令牌保存在 firestore 或其他地方 2-功能应用程序将在需要时检索它们以确保其安全

so where do I keep it and how can i retrieve those token?那么我应该把它放在哪里,我怎样才能取回这些令牌呢? firestore?火炉? some other service on cloud?云上的其他一些服务? maybe in the same firestore that the funcstions uses?也许在函数使用的同一个 firestore 中?

update : the way i think is更新:我认为的方式是

1 - create a bucket 1 - 创建一个桶

2- create 2 projects. 2- 创建 2 个项目。 - 1 for token generations, 2 fo the functions iteself - 1 个用于令牌生成,2 个用于函数本身

3- token generation will keep the token in bucket storage evrey 10 mintues 3- 代币生成会将代币保存在存储桶中 evrey 10 分钟

4- the function service will get the token from bucket evrey time 4- function 服务将在每个时间从桶中获取令牌

thanks谢谢

As mentioned in the answer 3rd party APIs can be stored in the firebase by following 3 ways:答案中所述,第三方 API 可以通过以下 3 种方式存储在 firebase 中:

  • If you truly want to use firebase functions to access your keys, then yes this can be done through firebase's On call Function .如果您真的想使用 firebase 函数来访问您的密钥,那么可以通过 firebase 的 On call Function来完成。

This sends a request to a function with that user's current auth state. You could then verify that the user is real and return the keys.More information on the protocol for sending this requests You can learn more about cloud firestore REST API as:这会使用该用户的当前身份验证 state 向 function 发送请求。然后您可以验证用户是否真实并返回密钥。有关发送此 请求的协议的更多信息您可以了解有关云 firestore REST API的更多信息,如下所示:

  • Accessing Cloud Firestore from a resource-constrained environment, such as an inte.net of things (IoT) device, where running a complete client library is impossible.从资源受限的环境(例如物联网 (IoT) 设备)访问 Cloud Firestore,在该环境中无法运行完整的客户端库。
  • Automating database administration or retrieving detailed database metadata.自动化数据库管理或检索详细的数据库元数据。 Here a documentation on how to use and manage API for the firebase projects.这里有一份关于如何为 firebase 项目使用和管理 API 的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM