git 我应该将 google-services.json(来自 Firebase)添加到我的存储库中吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37358340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:11:32  来源:igfitidea点击:

Should I add the google-services.json (from Firebase) to my repository?

gitversion-controlfirebase

提问by hitraj47

I just signed up with Firebase and I created a new project. Firebase asked me for my app domain and a SHA1 debug key. I input these details and it generated a google-services.json file for me to add in the root of my app module.

我刚刚注册了 Firebase 并创建了一个新项目。Firebase 询问我的应用域和 SHA1 调试密钥。我输入了这些详细信息,它生成了一个 google-services.json 文件供我添加到我的应用程序模块的根目录中。

My question is, should this .json file be added to a public (open source) repo. Is it something that should be secret, like an API key?

我的问题是,这个 .json 文件是否应该添加到公共(开源)存储库中。它是否应该保密,例如 API 密钥?

采纳答案by VonC

A google-services.jsonfile is, from the Firebase doc:

一个google-services.json文件来自 Firebase 文档

Firebase manages all of your API settings and credentials through a single configuration file.
The file is named google-services.jsonon Android and GoogleService-Info.pliston iOS.

Firebase 通过单个配置文件管理您的所有 API 设置和凭据。
该文件google-services.json在 Android 和GoogleService-Info.plistiOS 上均已命名。

It seems to make sense to add it to a .gitignoreand not include it in a public repo.
This was discussed in issue 26, with more details on what google-services.jsoncontains.

将它添加到 a.gitignore而不是将其包含在公共回购中似乎是有意义的。
这在第 26 期中讨论过,其中google-services.json包含有关内容的更多详细信息。

A project like googlesamples/google-servicesdoes have it in its .gitignorefor instance.
Although, as commentedby stepheaw, this thread does mention

像一个项目googlesamples/google-services确实有它在它.gitignore的实例。
虽然,正如stepheaw评论的,这个线程确实提到

For a library or open-source sample we do not include the JSON file because the intention is that users insert their own to point the code to their own backend.
That's why you won't see JSON files in most of our firebase repos on GitHub.

对于库或开源示例,我们不包含 JSON 文件,因为目的是让用户插入自己的文件以将代码指向他们自己的后端。
这就是为什么您在 GitHub 上的大多数 firebase 存储库中都看不到 JSON 文件的原因。

If the "database URL, Android API key, and storage bucket" are not secret for you, then you could consider adding the file to your repo.
As mentioned in "Is google-services.json safe from hackers?", this isn't that simple though.

如果“数据库 URL、Android API 密钥和存储桶”对您来说不是秘密,那么您可以考虑将该文件添加到您的存储库中。
正如“ google-services.json 是否免受黑客攻击?”中所述,但这并没有那么简单。

回答by Yaron

From thisdiscussion it seems you can add it to a public repo. Its content ends up in the APK anyway and is probably easy to extract.

这个讨论中,您似乎可以将其添加到公共存储库中。无论如何,它的内容最终会出现在 APK 中,并且可能很容易提取。