How to push code to Github hiding the API keys?

后端 未结 4 1624
死守一世寂寞
死守一世寂寞 2020-12-04 22:12

I want to push some codes to my GitHub Repository. These codes are in different languages like Javascript, Java, Python etc. Some of t

4条回答
  •  鱼传尺愫
    2020-12-04 22:21

    Having your API key in the code is probably a bad idea anyway. It means that anyone else that wants to use your code will have to edit the code and rebuild it.

    The textbook solution for such usecases is to move the credentials to some configuration file, and add clear documentation in the README.md file about how the configuration file's structure and location. You could also add an entry for it in your gitignore file to prevent yourself (and anyone else) from pushing your private information to GitHub by mistake.

提交回复
热议问题