gpt4 book ai didi

java - com.google.gdata.util.AuthenticationException : Error authenticating (check service name) due to this not able to read the google spreadsheets

转载 作者:行者123 更新时间:2023-12-01 18:29:29 24 4
gpt4 key购买 nike

我尝试从我的 JAVA 代码中阅读 google 文档。我已提供正确的访问凭据。但这仍然显示为身份验证异常。

 public static void main(String[] args) throws IOException, ServiceException
{

String status="";

try{
System.out.println("----");
SpreadsheetService service = new SpreadsheetService("Print Google Spreadsheet Demo"); System.out.println("Here "+service);
service.setUserCredentials(GOOGLE_ACCOUNT_USERNAME, GOOGLE_ACCOUNT_PASSWORD);
System.out.println("Here 1");
URL metafeedUrl = new URL(SPREADSHEET_URL);
SpreadsheetEntry spreadsheet = service.getEntry(metafeedUrl,SpreadsheetEntry.class);
URL listFeedUrl = spreadsheet.getWorksheets().get(0).getListFeedUrl();
ListFeed feed = service.getFeed(listFeedUrl, ListFeed.class);
for (ListEntry entry : feed.getEntries()) {
System.out.println("new row");
for (String tag : entry.getCustomElements().getTags())
{
System.out.println(" " + tag + ": "
+ entry.getCustomElements().getValue(tag));
status=entry.getCustomElements().getValue(tag);
}
}

}catch(Exception e){
System.out.println(e);
}
System.out.println(status);
}

com.google.gdata.util.AuthenticationException: Error authenticating (check service name)

最佳答案

您正在使用 ClientLogin 进行身份验证,该功能很久以前就已被弃用。您应该验证 via OAuth 2.0相反。

您可以找到清晰的分步指南,以使用 Java 进行身份验证并调用 Sheets API here 。您只需修改与API调用相关的部分即可。

here您可以在表格中找到针对不同可能的 API 调用的 Java(以及许多其他语言)代码片段。只需在左侧边栏中查找您要使用的方法(REST 资源)即可。

引用:

关于java - com.google.gdata.util.AuthenticationException : Error authenticating (check service name) due to this not able to read the google spreadsheets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60186519/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com