Android Question Dropbox Long Term Token

Brad Henderson

Member
Licensed User
Hello Everyone,

I am hoping someone has successfully tackled the Dropbox refresh token/access token maze (at least it is to me). I have been able to create a Refresh Token using THIS manual method using a Browser window and Windows Command Prompt (Terminal). It creates a long term Refresh Token that I can use to create a new temporary (4hr) access token using this in the Windows command prompt:

B4X:
curl https://api.dropbox.com/oauth2/token -d grant_type=refresh_token -d refresh_token=<Refresh Token> -u <App key>:<App secret>

My question is: Is there a way of executing this Curl command from within a B4A program? At the moment my app works with 4 hourly refresh requests from the user and would like this process to be invisible to the user.

Your help is appreciated
Brad
 

teddybear

Well-Known Member
Licensed User
2 solutions:
1. Directly run curl within phone shell
2. Use httpjob poststring to do that
 
Upvote 0

Brad Henderson

Member
Licensed User
Thank you teddybear,

I am new to both these methods. Using the "httpjob" how would I provide the variables: <Refresh Token> -u <App key>:<App secret>?

If I try to add them in the download command I get a 404 page not found, if I don't include them it hangs at "Wait For" JobDone.

Thanks for your help
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Download command is for GET, poststring is for POST method
Read httpjob documentation first, and then search for poststring and basic auth on the forums.
 
Upvote 0

Brad Henderson

Member
Licensed User
Thanks again teddybear

I've looked at the documentation and can see that poststring requires requires a link and a text parameter. From this curl command:

Curl:
curl https://api.dropbox.com/oauth2/token -d grant_type=refresh_token -d refresh_token=<Refresh Token> -u <App key>:<App secret>

I would guess that the link is "https://api.dropbox.com/oauth2/token" but where would I search to find the text component.?
 
Upvote 0
Top