0

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?

2
  • 2
    Neither. Store it outside the script and have the script read from the file(which isn't stored in any repository). Commented Nov 23, 2020 at 9:08
  • You only need to store it remotely (securely on the host server) if you’re going to deploy it somewhere. Otherwise keep it a “secret” (local file). Commented Nov 23, 2020 at 9:16

2 Answers 2

3

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 
Sign up to request clarification or add additional context in comments.

2 Comments

My API key will still be exposed. It that okay?
Of course you shouldnt be uploading the example.cfg! Thats only for your instance
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.