For rails, I used a gem called figaro.
You define environment-specific variables (config/application.yml):
CALENDAR_SCOPE: https://www.googleapis.com/auth/calendar
production:
CLIENT_ID: 393sdfgsdfg.apps.googleusercontent.com
CLIENT_SECRET: sdfgdfsgsg
OAUTH2_REDIRECT: http://mydomain/users/auth/google_oauth2/callback
etc...
development:
CLIENT_ID: 24asdfsadfas.apps.googleusercontent.com
CLIENT_SECRET: asdfsadf
OAUTH2_REDIRECT: http://localhost:3000/users/auth/google_oauth2/callback
etc....
You then use these in your code:
client = Google::APIClient.new({:auto_refresh_token => false})
client.authorization.scope = ENV['CALENDAR_SCOPE']
client.authorization.client_id = ENV['CLIENT_ID']
client.authorization.client_secret = ENV['CLIENT_SECRET']
client.authorization.redirect_uri = ENV['OAUTH2_REDIRECT']
etc...
You do have to remember to set the environment when starting the server. eg:
thin -e production start
or
thin -e development start
You probably would want to gitignore the application.yml file.