我从https://github.com/box/box-java-sdk-v2下载了最新的Box Java SDK,并按照自述文件中的说明运行示例HelloWorld程序。我在程序中更新了我的客户端ID和密钥,并执行了" ant run"。浏览器窗口打开,我可以用我的信用卡进行身份验证。重定向网址设置为:
http://localhost:4000
将代码发送到重定向网址后,我会收到以下异常。到目前为止,确认我的客户端ID,密钥和重定向URL都已在Box应用程序中正确配置。
由于我的重定向网址中没有https,因此我无法理解SSL错误发生的位置。我在Mac上运行它(Mavericks 10.9.4)。
java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
以下是异常消息:
run:
[java] GET /?state=&code=JeIYUCFq9meQFeRCNJZy2GbLzc2KOqaA HTTP/1.1
[java] com.box.restclientv2.exceptions.BoxRestException
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
[java] at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:606)
[java] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[java] at org.apache.tools.ant.Task.perform(Task.java:348)
[java] at org.apache.tools.ant.Target.execute(Target.java:435)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[java] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
[java] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[java] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[java] at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:851)
[java] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[java] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[java] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
[java] Caused by: com.box.restclientv2.exceptions.BoxRestException
[java] at com.box.boxjavalibv2.BoxRESTClient.handleException(BoxRESTClient.java:183)
[java] at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:118)
[java] at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:72)
[java] at com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParse(AbstractBoxResourceManager.java:118)
[java] at com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParseAndTryCast(AbstractBoxResourceManager.java:108)
[java] at com.box.boxjavalibv2.resourcemanagers.BoxOAuthManagerImpl.createOAuth(BoxOAuthManagerImpl.java:81)
[java] at com.box.boxjavalibv2.resourcemanagers.BoxOAuthManagerImpl.createOAuth(BoxOAuthManagerImpl.java:53)
[java] at HelloWorld.getAuthenticatedClient(HelloWorld.java:57)
[java] at HelloWorld.main(HelloWorld.java:39)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[java] at java.lang.reflect.Method.invoke(Method.java:606)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
[java] at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
[java] ... 21 more
[java] Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
[java] at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
[java] at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:126)
[java] at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:437)
[java] at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
[java] at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
[java] at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
[java] at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
[java] at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
[java] at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
[java] at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
[java] at com.box.boxjavalibv2.BoxRESTClient.getResponse(BoxRESTClient.java:148)
[java] at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:98)
[java] ... 34 more
[java] Java Result: -1
请告诉我是否应该尝试不同的事情。
谢谢!
答案 0 :(得分:0)
SSL错误是因为我的计算机上名为Netskope客户端的应用程序拦截了所有流量。一旦我禁用它,一切都开始正常。