【发布时间】:2012-09-16 10:05:46
【问题描述】:
我正在尝试获取访问令牌以使用 Google Play Android 开发者 API,而我使用 the Google API Java Client documentation example 做到了这一点:
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。我做错了什么,还是遗漏了一些步骤?
【问题讨论】:
-
还要检查stackoverflow.com/a/24264696/165708,您可能需要采取更多步骤才能使一切正常。
标签: authorization google-api oauth-2.0 credentials access-token