<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fatal error on running finishFromCode in Java 3.0.6 in Dropbox API Support &amp; Feedback</title>
    <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/264143#M15457</link>
    <description>&lt;P&gt;Thank you, it helps.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 18:38:12 GMT</pubDate>
    <dc:creator>john_son</dc:creator>
    <dc:date>2018-02-08T18:38:12Z</dc:date>
    <item>
      <title>Fatal error on running finishFromCode in Java 3.0.6</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/263473#M15393</link>
      <description>&lt;P&gt;Trying to run method finishOAuth of DropboxConnector class (startOAuth has no problems when running.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;public &lt;/SPAN&gt;DropboxConnector() {&lt;BR /&gt;    DbxAppInfo appInfo = &lt;SPAN&gt;new &lt;/SPAN&gt;DbxAppInfo(DropboxHelper.&lt;SPAN&gt;APP_KEY&lt;/SPAN&gt;, DropboxHelper.&lt;SPAN&gt;APP_SECRET&lt;/SPAN&gt;);&lt;BR /&gt;    &lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;config &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;DbxRequestConfig(&lt;SPAN&gt;"text-edit/0.1"&lt;/SPAN&gt;);&lt;BR /&gt;    &lt;SPAN&gt;this&lt;/SPAN&gt;.&lt;SPAN&gt;webAuth &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;DbxWebAuth(&lt;SPAN&gt;config&lt;/SPAN&gt;, appInfo);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public &lt;/SPAN&gt;String startOAuth(){&lt;BR /&gt;    DbxWebAuth.Request authRequest = DbxWebAuth.&lt;SPAN&gt;newRequestBuilder&lt;/SPAN&gt;().build();&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;&lt;SPAN&gt;webAuth&lt;/SPAN&gt;.authorize(authRequest);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;public &lt;/SPAN&gt;String finishOAuth(String code) &lt;SPAN&gt;throws &lt;/SPAN&gt;DbxException {&lt;BR /&gt;    DbxAuthFinish authFinish = &lt;SPAN&gt;webAuth&lt;/SPAN&gt;.finishFromCode(code);&lt;BR /&gt;    &lt;SPAN&gt;return &lt;/SPAN&gt;authFinish.getAccessToken();&lt;BR /&gt;}&lt;/PRE&gt;&lt;P&gt;getting Fatal Error on calling finishFromCode(code). Debug shows code is the same I get from dropbox auth page.&lt;/P&gt;&lt;P&gt;Here is the stack:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E/AndroidRuntime: FATAL EXCEPTION: main&lt;BR /&gt;Process: com.example.andrew.mywardrobe, PID: 7916&lt;BR /&gt;android.os.NetworkOnMainThreadException&lt;BR /&gt;at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1303)&lt;BR /&gt;at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:86)&lt;BR /&gt;at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)&lt;BR /&gt;at java.net.InetAddress.getAllByName(InetAddress.java:752)&lt;BR /&gt;at com.android.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)&lt;BR /&gt;at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:187)&lt;BR /&gt;at com.android.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)&lt;BR /&gt;at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)&lt;BR /&gt;at com.android.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:345)&lt;BR /&gt;at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:328)&lt;BR /&gt;at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:246)&lt;BR /&gt;at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:457)&lt;BR /&gt;at com.android.okhttp.internal.huc.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:126)&lt;BR /&gt;at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:257)&lt;BR /&gt;at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)&lt;BR /&gt;at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java)&lt;BR /&gt;at com.dropbox.core.http.StandardHttpRequestor.getOutputStream(StandardHttpRequestor.java:123)&lt;BR /&gt;at com.dropbox.core.http.StandardHttpRequestor.access$000(StandardHttpRequestor.java:28)&lt;BR /&gt;at com.dropbox.core.http.StandardHttpRequestor$Uploader.&amp;lt;init&amp;gt;(StandardHttpRequestor.java:133)&lt;BR /&gt;at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:72)&lt;BR /&gt;at com.dropbox.core.http.StandardHttpRequestor.startPost(StandardHttpRequestor.java:28)&lt;BR /&gt;at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:237)&lt;BR /&gt;at com.dropbox.core.DbxRequestUtil.startPostNoAuth(DbxRequestUtil.java:216)&lt;BR /&gt;at com.dropbox.core.DbxRequestUtil$2.run(DbxRequestUtil.java:453)&lt;BR /&gt;at com.dropbox.core.DbxRequestUtil.runAndRetry(DbxRequestUtil.java:498)&lt;BR /&gt;at com.dropbox.core.DbxRequestUtil.doPostNoAuth(DbxRequestUtil.java:450)&lt;BR /&gt;at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:401)&lt;BR /&gt;at com.dropbox.core.DbxWebAuth.finish(DbxWebAuth.java:383)&lt;BR /&gt;at com.dropbox.core.DbxWebAuth.finishFromCode(DbxWebAuth.java:295)&lt;BR /&gt;at com.example.andrew.mywardrobe.dropbox.DropboxConnector.finishOAuth(DropboxConnector.java:39)&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dropbox-core-sdk-3.0.6.jar is added to dependencies.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 May 2019 09:15:41 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/263473#M15393</guid>
      <dc:creator>john_son</dc:creator>
      <dc:date>2019-05-29T09:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal error on running finishFromCode in Java 3.0.6</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/263605#M15408</link>
      <description>You're getting a `NetworkOnMainThreadException`, which means you're trying to make a network call on the main thread, which isn't allowed on Android. (The `finishFromCode` method makes a network call to the Dropbox API servers to exchange the authorization code for an access token.)&lt;BR /&gt;&lt;BR /&gt;You would need to make this call on a background thread instead. There are various examples about how to do this on StackOverflow, e.g.: &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception" target="_blank"&gt;https://stackoverflow.com/questions/6343166/android-os-networkonmainthreadexception&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Note that for Android though, the Dropbox Java SDK provides a different app authorization flow anyway, which doesn't use finishFromCode. There's an example Android app here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-java/tree/master/examples/android&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Your AndroidManifest.xml should be set up as shown here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xml#L33" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/AndroidManifest.xml#L33&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You start the flow by calling startOAuth2Authentication as shown here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java#L36" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/UserActivity.java#L36&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;You complete the flow by calling getOAuth2Token as shown here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L22" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L22&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Your app can store and re-use the resulting access token for that user, as the example does here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L24" target="_blank"&gt;https://github.com/dropbox/dropbox-sdk-java/blob/master/examples/android/src/main/java/com/dropbox/core/examples/android/DropboxActivity.java#L24&lt;/A&gt;</description>
      <pubDate>Mon, 05 Feb 2018 16:16:45 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/263605#M15408</guid>
      <dc:creator>Greg-DB</dc:creator>
      <dc:date>2018-02-05T16:16:45Z</dc:date>
    </item>
    <item>
      <title>Re: Fatal error on running finishFromCode in Java 3.0.6</title>
      <link>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/264143#M15457</link>
      <description>&lt;P&gt;Thank you, it helps.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 18:38:12 GMT</pubDate>
      <guid>https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Fatal-error-on-running-finishFromCode-in-Java-3-0-6/m-p/264143#M15457</guid>
      <dc:creator>john_son</dc:creator>
      <dc:date>2018-02-08T18:38:12Z</dc:date>
    </item>
  </channel>
</rss>

