Created
November 30, 2020 03:19
-
-
Save cg4jins/633bc767167a41bf825187b6d307c677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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