很抱歉如果已经回答了这个问题,但我在这里没有找到任何相关内容。
我已经从一个软件自动开发应用程序数据源到谷歌电子表格。要获取Google的用户令牌,我使用Oauth2。 到目前为止,这在Windows 7上运行良好。 但是最近我已经迁移到Windows 10,当我运行相同的应用程序时,我得到了以下输出
线程中的异常" main" java.lang.NoClassDefFoundError: javax / servlet / http / HttpServletRequest at com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver.getRedirectUri(LocalServerReceiver.java:98) 在 com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp.authorize(AuthorizationCodeInstalledApp.java:76) 在 oauthtest.DriveAuthentication.authorize(DriveAuthentication.java:99) 在 oauthtest.DriveAuthentication.getDriveService(DriveAuthentication.java:111) at oauthtest.DriveAuthentication.main(DriveAuthentication.java:120) 引起:java.lang.ClassNotFoundException: javax.servlet.http.HttpServletRequest at java.net.URLClassLoader $ 1.run(URLClassLoader.java:366)at java.net.URLClassLoader $ 1.run(URLClassLoader.java:355)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:354)at java.lang.ClassLoader.loadClass(ClassLoader.java:425)at sun.misc.Launcher $ AppClassLoader.loadClass(Launcher.java:308)at at java.lang.ClassLoader.loadClass(ClassLoader.java:358)... 5更多
有代码乳头
以下是代码
public static Credential authorize() throws IOException {
// Load client secrets.
InputStream in =
DriveAuthentication.class.getResourceAsStream("client_secret.json");
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
// Build flow and trigger user authorization request.
GoogleAuthorizationCodeFlow flow =
new GoogleAuthorizationCodeFlow.Builder(
HTTP_TRANSPORT, JSON_FACTORY, clientSecrets, SCOPES)
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.build();
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
System.out.println(
"Credentials saved to " + DATA_STORE_DIR.getAbsolutePath());
return credential;
}
问题指向行
Credential credential = new AuthorizationCodeInstalledApp(
flow, new LocalServerReceiver()).authorize("user");
当我想第一次使用应用程序验证用户时。 如果我使用在WIN7上创建的凭据,它们适用于WIN10 w / o问题。
感谢您的任何想法