B4A Library [Library] Dropbox Authentication API ver 1

This library wraps the Dropbox SDK to do authentication.
I have only checked that I get the access token, I havent tested it ahead of that.

Required Files:
[I dont know how to include jar files into my lib, so we have to separately download the 3 sdk jar files and I created dummy xml files]

Libs:
In the Libs tab, select the following libs:
dropbox-android-sdk
httpmime-4.0.3
json_simple-1.1
DBWrapper

Manifest:
In your apps manifest add the following:
It will not work if you dont add your app key to the manifest.
B4X:
AddApplicationText(  <activity android:name="com.dropbox.client2.android.AuthActivity"
      android:launchMode="singleTask"
      android:configChanges="orientation|keyboard">
      <intent-filter>
        <!-- Change this to be db- followed by your app key -->
        <data android:scheme="db-YOUR_APPKEY" />
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.BROWSABLE"/>
        <category android:name="android.intent.category.DEFAULT" />
      </intent-filter>  </activity>)

The B4A code is simple:
B4X:
Sub Globals
   Dim d As DropboxWrapper 
End Sub

Sub Activity_Create(FirstTime As Boolean)

d.setAppKey("YOUR_APP_KEY","YOUR_APP_SECRET")
d.AccessLevel=d.AccessTypeDropbox 
d.startAuthentication 'This line will start the Dropbox app or Browser, you should add it to your Login button
End Sub

Sub Activity_Resume
d.resumeAuthentication 
If d.isAuthenticated Then
   Log("AccesToken:" & d.AccessTokenKey & " AccessSecret:" & d.AccessTokenSecret)
Else
   Log("Not Authenticated")
End If
End Sub

You will need to modify Erel's example to use these Access Keys and the new API ver 1. I have not tried it.
Also look in the logs pane for any messages or errors.

UPDATE:
Uploaded a new version that deals with Login Resume better.
If the OS runs low on memory, and when launching the browser to authenticate with DB, it closes your app, then login used to fail. This has been fixed in version 1.1.
 

Attachments

  • DBWrapper.zip
    4.9 KB · Views: 534
  • lib.jpg
    lib.jpg
    24.9 KB · Views: 426
  • DBWrapper1.1.zip
    4.4 KB · Views: 401
Last edited:

JorgeMC

Member
Licensed User
Longtime User
Good afternoon, I finally had time to test your library and working properly, but now I have some doubts:

1, Could someone gather all the files into one, except of course dropbox sdk?

2 ° How can you do to send a file to a Dropbox folder, so that it always this date?

Thanks in advance.
 

thedesolatesoul

Expert
Licensed User
Longtime User
1, Could someone gather all the files into one, except of course dropbox sdk?
I dont know how to do this. There are some discussions on the forum regarding this but there is no solution to pack all the jar files into one.

2 ° How can you do to send a file to a Dropbox folder, so that it always this date?
I dont understand this question. Do you want to change the date on the file? I dont think this is possible. Dropbox will only use the 'upload' date.
 

sellnet

New Member
Licensed User
Longtime User
Next steps after authentication

I've successfully used this to autheticate. I have tried modifying Erel's example to use the token I get back to upload a file, but I have failed miserably.

Can ayone provide any guidance or an example of how to upload a file once you have used this lbrary to authenticate please?

Thanks.
 

thedesolatesoul

Expert
Licensed User
Longtime User
I've successfully used this to autheticate. I have tried modifying Erel's example to use the token I get back to upload a file, but I have failed miserably.

Can ayone provide any guidance or an example of how to upload a file once you have used this lbrary to authenticate please?

Thanks.

Once you get the token place it in the OAuth object.
Make sure you do not use any of the old authentication methods, you can remove this line completelyfor e.g.
B4X:
   tokenLink        = "https://api.dropbox.com/0/token?"

Also change the API version on *ALL* the links from 0 to 1:
B4X:
metadataLink     = "https://api.dropbox.com/0/metadata/dropbox"
to
B4X:
metadataLink     = "https://api.dropbox.com/1/metadata/dropbox"
If you still encounter errors you will have to provide more information, like that error/response you get in the logs.
 

islandman

Member
Licensed User
Longtime User
Good job but...

Once you get the token place it in the OAuth object.
Make sure you do not use any of the old authentication methods, you can remove this line completelyfor e.g.
B4X:
   tokenLink        = "https://api.dropbox.com/0/token?"

Also change the API version on *ALL* the links from 0 to 1:
B4X:
metadataLink     = "https://api.dropbox.com/0/metadata/dropbox"
to
B4X:
metadataLink     = "https://api.dropbox.com/1/metadata/dropbox"
If you still encounter errors you will have to provide more information, like that error/response you get in the logs.

I did all that but i don't know what to change in the Erel's example..:BangHead:

Could you help me please ?
Regards:sign0013: cuz i'm a :sign0104:
 

Kbogle24

Member
Licensed User
Longtime User
I have read every post and tried about everything I can find on dropbox. Can someone make an example project I can look at? I am so lost and confused right now.

:confused:
 

thedesolatesoul

Expert
Licensed User
Longtime User
I have read every post and tried about everything I can find on dropbox. Can someone make an example project I can look at? I am so lost and confused right now.

:confused:
I will prepare a *basic* example soon. My sample writer is on holiday these days, so I need to wait for him. :)
 

Kbogle24

Member
Licensed User
Longtime User
I wish I could wrap my head around writing a wrapper.... I still have so much to learn it hurts. I forgot to post my question in the post. what I was trying to get at was ... can this be done with your library? sorry for the confusion. sometimes I think a thought and never type it...:sign0013:
 

thedesolatesoul

Expert
Licensed User
Longtime User
I wish I could wrap my head around writing a wrapper.... I still have so much to learn it hurts. I forgot to post my question in the post. what I was trying to get at was ... can this be done with your library? sorry for the confusion. sometimes I think a thought and never type it...:sign0013:
The Sync API is completely different, and has a different sdk. It will have to be wrapped.
 
Top