问题描述
我正在为 iOS 开发,我需要使用 API 密钥和机密向某些 API 发出请求.但是,我不希望它在我的源代码中公开,并在我推送到我的存储库时泄露机密.
I'm developing for iOS and I need to make requests to certain APIs using an API key and a secret. However, I wouldn't like for it to be exposed in my source code and have the secret compromised when I push to my repository.
这种情况下的最佳做法是什么?将它写在一个单独的文件中,我将包含在 .gitignore 中?
What is the best practice for this case? Write it in a separate file which I'll include in .gitignore?
谢谢
推荐答案
这是一个非常古老的问题,但是如果有人在 google 中看到这个问题,我建议您尝试使用 CloudKit 来存储任何应用程序机密(API 密钥、Oauth 机密).只有您的应用程序可以访问您的应用程序容器,并且 Apple 和您的应用程序之间的通信是安全的.您可以在此处查看.
This is a very old question, but if anyone is seeing this in google I would suggest you try CloudKit for storing any App secrets (API keys, Oauth secrets). Only your app can access your app container and communication between Apple and your app is secure.You can check it out here.
这篇关于iOS 应用程序中使用的 API 密钥和秘密 - 将它们存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!