Skip to content

Instantly share code, notes, and snippets.

@julioz
Created April 27, 2016 00:31
Show Gist options
  • Save julioz/9ad47052cf2f9ec1cdbd99747dc82872 to your computer and use it in GitHub Desktop.
Save julioz/9ad47052cf2f9ec1cdbd99747dc82872 to your computer and use it in GitHub Desktop.
GoogleCredential instantiation
NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();
JacksonFactory json = JacksonFactory.getDefaultInstance();
Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER);
File secretFile = new File(Constants.SECRET_FILE_PATH);
GoogleCredential credential = new GoogleCredential.Builder().
setTransport(http).
setJsonFactory(json).
setServiceAccountPrivateKeyId(Constants.KEY_ID).
setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL).
setServiceAccountScopes(scopes).
setServiceAccountPrivateKeyFromPemFile(secretFile).
build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment