I’m writing a small c program which connects to the google api via Oauth2.
Therefore I need to send a client secret to google.
I store this secret in my code, which I want to push to github, but how can I avoid to show my client secret to everybody who looks at my code?
I’m writing a small c program which connects to the google api via Oauth2.
Share
use a configuration file where you’ll store the API key… you have many options, the simplest being writing the key directly into the file, more sophisticated being using some kind of serializers (like json, xml, inifile etc…), the right option is up to you (usually, you’ll want to serialize if you want to store several options in the file).
You can also set the key as a program argument, if you don’t mind the key to be visible in the process list of your host.
And be sure not to push your already existing git history to git hub, but create a new repository, or all your previous patches (with the key) will be public 😉