Reputation: 89
So I'm working on with an api from IsThereAnyDeals and I'm wondering where I should store my API key? Is it possible to store it remotely or is it fine to just store it inside the script?
Upvotes: 0
Views: 2202
Reputation: 11
You can add your cfg file to .gitignore, so that this file doesn't get uploaded, when you do a git commit.
You can read more about that topic here: How to ignore certain files in Git
Upvotes: 1
Reputation: 1669
ConfigParser is a good choice to setup your configuration-files in Python.
Something like this:
import configparser
cfg = configparser.ConfigParser()
cfg.read('example.cfg')
print(cfg.get('KEYS', 'api_key', raw=''))
example.cfg
:
[KEYS]
api_key: @#$@GSSAS
Upvotes: 3