在创建凭证对象时,当它尝试从p12设置私钥时,它会失败并显示错误“java.io.IOException:解码PKCS 12输入时出错”:
InputStream content = ..... // logic to get input stream
File file = new File("Analytics-data-retrieval.p12");
FileUtils.copyInputStreamToFile(content, file);
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
.setServiceAccountPrivateKeyFromP12File(file)
.setServiceAccountScopes(AnalyticsReportingScopes.all())
.build();