I am new to Elixir and decided to create my very first Elixir application using the Phoenix framework. My application uses github for logging and storing my application’s client id and client secret in an environment variable became a requirement when I wanted to push my repo to github publicly.
Luckily, Elixir makes it very easy to store and access environment variables. In my config.exs file I had the following configuration for github using Ueberauth for authentication.
config :ueberauth, Ueberauth.Strategy.Github.OAuth,
I then created a .env file under the config directory with the following:
export GITHUB_CLIENT_ID="<My Github client id>"
export GITHUB_CLIENT_SECRET="<My Github Client Secret>"
I also added config/.env to my .gitignore file to make sure my client id and secret are not committed and pushed to my public repo. Now before running mix phoenix.server I need to run source config/.env