tôi đang cố gắng để có được một thẻ truy cập để sử dụng Google Play API cho nhà phát triển Android, và tôi đã nhận này đến nay sử dụng the Google API Java Client documentation example:Cách nhận mã thông báo truy cập từ GoogleCredential?
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();
Nhưng làm thế nào để có mã thông báo truy cập từ chứng chỉ này? credential.getAccessToken()
trả lại null
. Tôi đang làm điều gì đó sai, hoặc thiếu một số bước?
Ngoài ra, hãy kiểm tra http://stackoverflow.com/a/24264696/165708 một số bước khác mà bạn có thể cần thực hiện để làm mọi thứ hoạt động. –