I am writing a Google App Engine (Java) application that reads data from a number of REST services, using OAuth for authentication. In order to support OAuth callbacks in my Development and Online environments, I have created 2 separate OAuth keys for the REST services – 1 that does a callback to 127.0.0.1 (development server) and 1 that does a callback to my real GAE website URL. This all works fine and happy.
Currently, to support this, I basically have a number of these statements throughout my code, anywhere that needs different values for Dev vs Online…
String devServer = request.getServerName();
if (devServer != null && devServer .equals("127.0.0.1")){
oauthKey = "<my_dev_key>";
}
else {
oauthKey = "<my_online_key>";
}
I was wondering whether GAE has any ability to auto-substitute different values for Development vs Online. I was thinking something like a ‘settings’ file that specifies 2 different values for a single setting, such that when the app is uploaded to GAE it replaces all setting references with the Online values. I would prefer that the values are substituted at upload-time rather than having a file sitting on the server with my Development settings in it, for security purposes.
Are there any alternatives that would be able to achieve a similar result without too much manual work every time I wish to upload a new version to GAE?
I would store the credential in different
Propertiesfiles using something like Maven and its Profile feature to build an artifact for any specific environment.Have a look to this project for the Google App Engine Maven plugin.