}
return credential.getAccessToken();
}
AppAdmin createAppAdmin(GenericApplication app) throws IOException {
AppAdminFactory appAdminFactory = new AppAdminFactory();
/**
if (options.getJavaExecutableOSPath() != null) {
appAdminFactory.setJavaExecutable(new File(options.getJavaExecutableOSPath()));
}
if (options.getJavaCompilerExecutableOSPath() != null) {
appAdminFactory.setJavaCompiler(new File(options.getJavaCompilerExecutableOSPath()));
}
*/
final AppAdminFactory.ConnectOptions appEngineConnectOptions = new AppAdminFactory.ConnectOptions();
// APPENGINE_SERVER is server to upload the app.
// The default is appspot.com, which is used for both upload and test container.
String appengineServer = System.getenv("APPENGINE_SERVER");
if (appengineServer != null) {
appEngineConnectOptions.setServer(appengineServer);
}
// User/Password
appEngineConnectOptions.setUserId(configuration.getUserId());
// TODO -- better prompt?
appEngineConnectOptions.setPasswordPrompt(new AppAdminFactory.PasswordPrompt() {
public String getPassword() {
return configuration.getPassword();
}
});
// OAuth2
String oauthToken = null;
String configOauthToken = configuration.getOauth2token(); // -Dappengine.oauth2token=
if (configOauthToken != null) {
if (configOauthToken.trim().equals("")) { // if blank token, get it from cookie.
oauthToken = getOAuthToken();
} else {
oauthToken = configOauthToken;
}
}
// if oauthToken is null, username/pw will be used.
appEngineConnectOptions.setOauthToken(oauthToken);
PrintWriter errorWriter = new PrintWriter(System.err, true);
return appAdminFactory.createAppAdmin(appEngineConnectOptions, app, errorWriter);
}