Skip to content

Instantly share code, notes, and snippets.

@cg4jins
Created November 30, 2020 03:19
Show Gist options
  • Save cg4jins/633bc767167a41bf825187b6d307c677 to your computer and use it in GitHub Desktop.
Save cg4jins/633bc767167a41bf825187b6d307c677 to your computer and use it in GitHub Desktop.
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = JacksonFactory.getDefaultInstance();
// Google Cloud Platform에서 발급 받은 인증서 파일입니다.
InputStream inputStream = getClass().getResourceAsStream(p12FilePath);
// Google Cloud Platform에서 인증서를 발급 받은 서비스 계정명입니다.
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(
Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER))
.setServiceAccountPrivateKeyFromP12File(inputStream)
.build();
credential.refreshToken();
return credential.getAccessToken();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment