B4A Class Dropbox API V2. All HTTP! All using httputils2

rafaelmotaquintana

Active Member
Licensed User
When trying to use the sample code to get the user token, I get this error from dropbox:

Error (400)
It seems the app you were using submitted a bad request. If you would like to report this error to the app's developer, include the information below.


More details for developers
Invalid redirect_uri. It must exactly match one of the redirect URIs you've pre-configured for your app (including the path

it happens in this line

www.LoadUrl("https://www.dropbox.com/1/oauth2/authorize?client_id="& Main.clientID &"&response_type=token&redirect_uri=http://127.0.0.1/")



WHat Am I missing?
Thanks
 

DonManfred

Expert
Licensed User
Longtime User
More details for developers
Invalid redirect_uri. It must exactly match one of the redirect URIs you've pre-configured for your app (including the path
Did you check this error? For the code you posted you need to have configured the url http://127.0.0.1/ when creating the app in the Dropbox developer console

 

rafaelmotaquintana

Active Member
Licensed User
Does anybody happens to know how to test if a folder exists?
Using listfolder, listfolders or search works if the folder exists, but if it doesn't exists, no event is raised so I can not know.
 

rafaelmotaquintana

Active Member
Licensed User
While uploading a file, If the device goes to idle (screen off), after turn it on, activity resume is launched.
How do I know if there's a dropbox operation currently running, like download or upload?
 

rafaelmotaquintana

Active Member
Licensed User
Ok I understand. By the way, I made this experiment, while uploading a big file, I disconnected the device from the internet, and I'd like to know if there's an event that raises so I could check if there is a problem. I the meantime, a message 'Uploading file' keeps forever displayed.
 

divinglog

Member
Licensed User
Longtime User
Hi

When I download large files (around 50 MB, sometimes less), my app is closed by Android because of an OutOfMemoryError. Is there a workaround for this problem? Here is the stack trace:

B4X:
java.lang.OutOfMemoryError: Failed to allocate a 69075310 byte allocation with 16777216 free bytes and 47MB until OOM
    at java.lang.AbstractStringBuilder.enlargeBuffer(AbstractStringBuilder.java:95)
    at java.lang.AbstractStringBuilder.append0(AbstractStringBuilder.java:115)
    at java.lang.StringBuilder.append(StringBuilder.java:249)
    at anywheresoftware.b4a.objects.streams.File$TextReaderWrapper.ReadAll(File.java:590)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring2(httpjob.java:189)
    at anywheresoftware.b4a.samples.httputils2.httpjob._getstring(httpjob.java:174)
    at b4a.example.dropbox._jobdone(dropbox.java:1891)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at anywheresoftware.b4a.keywords.Common$5.run(Common.java:996)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6873)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
 

divinglog

Member
Licensed User
Longtime User
I think the problem is in the httputils2 lib, not directly in the Dropbox lib. It's a SQLite database file, but the app is closed in the middle of the download, so I do nothing with the file yet. Here is the relevant part of the code:

B4X:
Sub Class_Globals
   Private dbx As DropBox
End Sub

Public Sub DownloadFile(RemoteFile As String)
    Dim Tempstr As String
    Dim LocalPath As String
    Dim LocalFile As String
   
    Tempstr = DivelogFolder & "/" & RemoteFile
   
    If Command = "DownloadMF" Then
        LocalPath = File.DirInternal
        LocalFile = m_MetadataFile
    Else
        LocalPath = Common.LogDir
        LocalFile = m_SyncInfo.SqliteFile
    End If
   
    Try
        dbx.Download(Tempstr, LocalPath, LocalFile)
    Catch
        If Command = "DownloadMF" Then
            DeleteMetadataFile
            m_AvailableLogbooks.Clear
            m_SyncInfo.Available = False
            If SubExists(m_Callback, m_Event & "_SyncInfoChanged") Then
                CallSub(m_Callback, m_Event & "_SyncInfoChanged")
            End If
        Else
            Log(LastException)
            ToastMessageShow(Command & " Error: " & LastException, True)
        End If
    End Try
   
End Sub
 

pappicio

Active Member
Licensed User
Longtime User
Hi all, is possible to have an example with download, upload and list? I'm trying to use this lbrary, but without any success.
thanks.

EDIT:
Okok, all listed into class src. thanks a lot.
 
Last edited:

SNOUHyhQs2

Member
Licensed User
Longtime User
Hi!
In FileUpload, is there an event that will trigger Upload Fail?

UploadSessionStatus doesn't seem to trigger upload fail, i tried it without network connection but it does not work.
 

Mikonios

Active Member
Licensed User
Longtime User
Hello DonManfred:

I have developped a project with B4A-V3.82.
Communicating through emails and ftp with different servers.
I want to expand communications via DropBox.
I see The Sync API has-been deprecated.
As is impossible DropBox V3.82.

Supports your new Dropbox API V2 with B4A-V3.82?
I need to acquire new version of B4a?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…