Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Trying to run method finishOAuth of DropboxConnector class (startOAuth has no problems when running.
public DropboxConnector() {
DbxAppInfo appInfo = new DbxAppInfo(DropboxHelper.APP_KEY, DropboxHelper.APP_SECRET);
this.config = new DbxRequestConfig("text-edit/0.1");
this.webAuth = new DbxWebAuth(config, appInfo);
}
public String startOAuth(){
DbxWebAuth.Request authRequest = DbxWebAuth.newRequestBuilder().build();
return webAuth.authorize(authRequest);
}
public String finishOAuth(String code) throws DbxException {
DbxAuthFinish authFinish = webAuth.finishFromCode(code);
return authFinish.getAccessToken();
}
getting Fatal Error on calling finishFromCode(code). Debug shows code is the same I get from dropbox auth page.
Here is the stack:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.andrew.mywardrobe, PID: 7916
android.os.NetworkOnMainThreadException
at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
at java.net.InetAddress.getAllByName(InetAddress.java:752)
at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)
at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)
at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)
at com.dropbox.core.http.StandardHttpRequestor.getOutputStream(StandardHttpRequestor.java:123)
at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:28)
at com.dropbox.core.http.StandardHttpRequestor$Uploader.<init>(StandardHttpRequestor.java:133)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:72)
at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:28)
at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:237)
at com.dropbox.core.DbxRequestUtil.startPostNoAuth(DbxRequestUtil.java:216)
at com.dropbox.core.DbxRequestUtil$2.run(DbxRequestUtil.java:453)
at com.dropbox.core.DbxRequestUtil.runAndRetry(DbxRequestUtil.java:498)
at com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:450)
at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:401)
at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:383)
at com.dropbox.core.DbxWebAuth.finishFromCode(DbxWebAuth.java:295)
at com.example.andrew.mywardrobe.dropbox.DropboxConnector.finishOAuth(DropboxConnector.java:39)
dropbox-core-sdk-3.0.6.jar is added to dependencies.
Thank you, it helps.
The wierd thing is the project was cloned from Windows Android Studio , where the code works without any issues to Macbook one where the issue immediately happened.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on Twitter or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!