Note that there are some explanatory texts on larger screens.

plurals
  1. PODropbox Java API with GWT Authentication problems
    text
    copied!<p>I am using version 1.6 of the Dropbox API for Java found here: <a href="https://www.dropbox.com/developers/core/sdks/java" rel="nofollow">https://www.dropbox.com/developers/core/sdks/java</a></p> <p>I am also using GWT 2.5.1 in Eclipse 3.7</p> <p>I have the following code which works when run as a Java Applcation:</p> <pre><code> DbxRequestConfig requestConfig = new DbxRequestConfig(type, locale); DbxAppInfo appInfo = new DbxAppInfo(APP_ID, APP_SECRET); DbxWebAuthNoRedirect webauth = new DbxWebAuthNoRedirect(requestConfig, appInfo); String result = webauth.start(); System.out.println(result); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String code = reader.readLine(); webauth = new DbxWebAuthNoRedirect(requestConfig, appInfo); DbxAuthFinish finish = webauth.finish(code); DbxClient client = new DbxClient(requestConfig, finish.accessToken); DbxAccountInfo info = client.getAccountInfo(); long total = info.quota.total; long used = info.quota.normal; System.out.println("total: " + total); System.out.println("used: " + used); </code></pre> <p>This works just fin when I run it as a Java Application. However, when I try to do something similar with GWT within a RemoteServiceServlet. I get an exception when I try to do </p> <pre><code>webauth = new DbxWebAuthNoRedirect(requestConfig, appInfo); </code></pre> <p>The exception I am getting is the following:</p> <pre><code>Caused by: java.lang.ClassCastException: com.google.apphosting.utils.security.urlfetch.URLFetchServiceStreamHandler$Connection cannot be cast to javax.net.ssl.HttpsURLConnection at com.dropbox.core.http.StandardHttpRequestor.prepRequest(StandardHttpRequestor.java:160) at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:87) at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:21) at com.dropbox.core.DbxRequestUtil.startPostNoAuth(DbxRequestUtil.java:156) at com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:289) at com.dropbox.core.DbxWebAuthHelper.finish(DbxWebAuthHelper.java:40) at com.dropbox.core.DbxWebAuthNoRedirect.finish(DbxWebAuthNoRedirect.java:84) at com.cloudshare.server.DropboxPlayground.getFinish(DropboxPlayground.java:21) at com.cloudshare.server.DropboxServiceImpl.authenticate(DropboxServiceImpl.java:70) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at com.google.appengine.tools.development.agent.runtime.Runtime.invoke(Runtime.java:115) at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:561) ... 40 more </code></pre> <p>I have been banging my head against a wall for last couple of hours trying to figure out what is going on. I originally wanted to use a DbxWebAuth but the documentation in their API includes instructions that have classes that don't exist (I am assuming they did at one time).</p> <p>I feel like the DbxWebAuthNoRedirect is doing something where it is dynamically loading a connection based on the classes that are available. But I have not been able to figure it out.</p> <p>Thanks in advance for the help!</p> <p>EDITS:</p> <p>Okay, so I looked at the Dropbox API source and the error is occurring here:</p> <pre><code> URL urlObject = new URL(url); HttpsURLConnection conn = (HttpsURLConnection) urlObject.openConnection(this.proxy); </code></pre> <p>Because I am using Google App Engine, it is using its own URL object rather than the one imported by the App Engine API. Any ideas on a solution that doesn't involve writting a GWT wrapper for the Dropbox API.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload