Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/373.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google Sheets API V4(Java)/如何将凭证传递给Sheets对象?_Java_Google Sheets Api_Google Oauth - Fatal编程技术网

Google Sheets API V4(Java)/如何将凭证传递给Sheets对象?

Google Sheets API V4(Java)/如何将凭证传递给Sheets对象?,java,google-sheets-api,google-oauth,Java,Google Sheets Api,Google Oauth,,第三个参数是凭证,但在API文档中,它是httpRequestInitializer。 我得到编译错误 快速启动中的示例代码() ■API文件() ■环境 java 1.8 表单库com.google.api:googleapi服务表单:v4-rev581-1.25.0 解决方案 在您的示例中,您使用的是GoogleCredentials类,根据这一点,该类已被弃用,而Quickstart示例使用的是com.google.api.client.auth.oauth2.Credential包

,第三个参数是凭证,但在API文档中,它是httpRequestInitializer。 我得到编译错误

快速启动中的示例代码()

■API文件()

■环境

  • java 1.8
  • 表单库
    com.google.api:googleapi服务表单:v4-rev581-1.25.0
解决方案 在您的示例中,您使用的是
GoogleCredentials
类,根据这一点,该类已被弃用,而Quickstart示例使用的是
com.google.api.client.auth.oauth2.Credential
包中的
Credential


Credential
类实现了
HttpRequestInitializer
接口,使用它您不会产生任何编译错误。在处快速入门是学习如何在Sheets service builder中使用
Credential
类的完美起点。

快速入门不适合您吗?你能发布错误堆栈跟踪吗?谢谢你的Alessandro。没有堆栈跟踪。因为它由于编译错误而无法执行。所以快速启动不适用于您?是的。不工作。这真的很奇怪,快速入门按照说明运行良好。您可以发布尝试运行快速启动时出现的错误吗?另外,请查看以获取更多帮助。
new Sheets.Builder(HTTP_TRANSPORT, JSON_ FACTORY, ★getCredentials(HTTP_TRANSPORT)★)
Builder(HttpTransport, JsonFactory, ★httpRequestInitializer★)