【发布时间】:2023-05-13 03:45:01
【问题描述】:
我想用一个简单的 Java 程序计算的数值更新电子表格。 它不是一个 Android 应用程序或任何东西,只是普通的 java。
问题是程序退出我说帐户无效。 但是提供的凭据是 100% 有效的 - 我将它们从 eclipse 中复制出来并将它们粘贴到 gmail 登录表单中 - 它们可以工作..
类(这是api教程中的基础类):
import com.google.gdata.client.spreadsheet.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;
import java.io.IOException;
import java.net.*;
public class MySpreadsheetIntegration {
public static void main(String[] args)
throws AuthenticationException, MalformedURLException, IOException, ServiceException {
String USERNAME = "abc@gmail.com";
String PASSWORD = "123";
SpreadsheetService service =
new SpreadsheetService("MySpreadsheetIntegration-v1");
service.setUserCredentials(USERNAME, PASSWORD);
// TODO: See other portions of this guide for code to put here...
}
}
堆栈跟踪:
Exception in thread "main" com.google.gdata.client.GoogleService$InvalidCredentialsException: Invalid credentials
at com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(GoogleAuthTokenFactory.java:660)
at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:560)
at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303)
at MySpreadsheetIntegration.main(MySpreadsheetIntegration.java:17)
我想知道这甚至可以使用没有 android sdk 和其他东西的 api 吗?
【问题讨论】:
标签: java google-sheets gdata