Skip to content

Commit

Permalink
Merge pull request #378 from ajkannan/reflection-fix
Browse files Browse the repository at this point in the history
Fix code to get App Engine project ID
  • Loading branch information
aozarov committed Nov 13, 2015
2 parents 6890fa1 + f3c8274 commit b67dad7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,11 @@ protected static String getAppEngineProjectId() {
try {
Class<?> factoryClass =
Class.forName("com.google.appengine.api.appidentity.AppIdentityServiceFactory");
Class<?> serviceClass =
Class.forName("com.google.appengine.api.appidentity.AppIdentityService");
Method method = factoryClass.getMethod("getAppIdentityService");
Object appIdentityService = method.invoke(null);
method = appIdentityService.getClass().getMethod("getServiceAccountName");
method = serviceClass.getMethod("getServiceAccountName");
String serviceAccountName = (String) method.invoke(appIdentityService);
int indexOfAtSign = serviceAccountName.indexOf('@');
return serviceAccountName.substring(0, indexOfAtSign);
Expand Down

0 comments on commit b67dad7

Please sign in to comment.