How to make sure API tokens and passwords stay away from github

I am considering publishing a project on github. It may contain sensitive data, such as API tokens, which I naturally do not want publicly. I would like to use the code locally with the correct tokens, passwords, etc., but only the repositories should go to the repository.

I could try to forget to delete this data every time before clicking (manually, automatically?), But then the local and github copies are obviously different, and this seems to be error prone.

What is good practice for this situation?

+4
source share
1 answer

EDIT: , . , :
?

--- ---

. . : API -

api .

.gitignore:

##################
#Ignore API token#
##################
token.txt

( python):

#import token from token.txt file in same directory
token_file = os.path.join(path, "token.txt")

with open(token_file, 'rb') as f:
    token = f.read().replace('\n', '')

, .

+3

Source: https://habr.com/ru/post/1526777/


All Articles