java如何使用电子表格API作为批处理程序?
我做了一个批处理程序,可以得到一些电子表格,并用客户端登录方法更新它们。 它一直移动到5月26日。 但是,由于身份验证错误的发生,它现在不再工作
我想使用cron为电子表格执行一个批处理程序。 因此,我尝试阅读以下页面并迁移到OAuth2。0方法
https://developers.google.com/api-client-library/java/google-api-java-client/client-login https://developers.google.com/google-apps/spreadsheets/authorize
然而,我无法理解如何使用OAuth2。0作为Java代码中的批处理。 我想知道的是一种身份验证方法,在运行电子表格API时,它不需要手动操作
请告诉我这个问题的解决办法
多谢各位
// current java source code
public static SpreadsheetService getService() {
SpreadsheetService service = new SpreadsheetService("MySpreadsheetIntegration");
service.setProtocolVersion(SpreadsheetService.Versions.V3);
// get Username and Password from JSON file
String username = getValueJsonFile("Username", JSON_FILE);
String password = getValueJsonFile("Password", JSON_FILE);
try {
service.setUserCredentials(username, password);
} catch (AuthenticationException e) {
e.printStackTrace();
System.out.println("Error code: " + e.getCodeName());
log.error(getMessage("WRONG_USER_PASS"));
}
return service;
}
共 (0) 个答案