Paweł Kosiński Paweł Kosiński - 9 months ago 132
Python Question

TweePy - how to hide API key

I am building simple app which is using Twitter API. What I have to do to hide my Twitter app keys? For example, if I will put my program to the internet and somebody who look up to the code will know my consumer key, access token etc. And if I not include this information into my program, that it won't be work!

Answer Source

I'm assuming by putting on the internet you mean publishing your code on github or such.

In that case you should always separate code and configuration. Put your API keys in an .ini file, i.e. config.ini, then load that file from python program using configparser

Add configuration file to your .gitignore so it would not get added to the source control.