You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

john_son's avatar
john_son
New member | Level 2
7 years ago

Fatal error on running finishFromCode in Java 3.0.6

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.