我正在尝试获取访问令牌以使用 Google Play Android Developer API,而我使用Google API Java Client 文档示例已经做到了这一点:
HttpTransport HTTP_TRANSPORT = new NetHttpTransport();
JsonFactory JSON_FACTORY = new JacksonFactory();
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("...gserviceaccount.com")
.setServiceAccountScopes("https://www.googleapis.com/auth/androidpublisher")
.setServiceAccountPrivateKeyFromP12File(keyFile)
.build();
但是如何从这个凭证中获取访问令牌?credential.getAccessToken()
返回null
。我做错了什么,还是错过了一些步骤?