tAdvDropBox Refresh Acces function Not working


As dropbox will stop supporting new long lived acces tokens in the future, i am trying to be prepared and want to implement the refreshacces function but i can't seem to get it to work. I contacted support but they told me that the vlc component does not support it but the fmx component does. So i tested it with the TMSFMXCloudDropBox component but it has the exact same problem as AdvDropBox.

This is the code i use

AdvDropBox1.PersistTokens.Key := '.\DROPBOXTOKENS.INI';
AdvDropBox1.PersistTokens.Location := CloudBase.plinifile;
AdvDropBox1.PersistTokens.Section := 'TOKENS';
AdvDropBox1.ExternalBrowser := true;
AdvDropBox1.app.Key := '3574r9q346i7hgo';
AdvDropBox1.app.secret := '38367s8t835bx1f';

AdvDropBox1.DoAuth (i have to auth once in the webpage that opens which works fine)

AdvDropBox1.Connect (works ok)

AdvDropBox1.TestTokens (is true)

AdvDropBox1.RefreshAccess (fails)

What i also noticed is that in the ini the refreshacces token is missing


Any help would be much appreciated


Please note that the possibility to refresh access tokens was only added recently to the DropBox API.
Unfortunately it's currently not supported to refresh access tokens for DropBox in both TMS VCL Cloud Pack and TMS FMX Cloud Pack.
We'll have to investigate if this feature can be added in the future.

Alternatively you can use TMS FNC Cloud Pack instead. This product also allows access to DropBox from VCL applications and already includes support to refresh DropBox access tokens.
More information and a trial version can be found at:

So this is partly my fault, as i tried the fmx instead of the fnc component,I still find it a bit odd the fnc component does support the refresh but not the vlc component.

I tried the FNC component and it indeed does get the refresh token, as i can only test this after 4 hours when the short-lived token is invalid i suspect the client will take care of the refresh if i try to connect after more then 4 hours ?

The adapted code for the interested:

TMSFNCCloudDropBox1.PersistTokens.Key := '.\DROPBOXTOKENS.INI';
TMSFNCCloudDropBox1.PersistTokens.Location := plIniFile;
TMSFNCCloudDropBox1.PersistTokens.Section := 'TOKENS';
TMSFNCCloudDropBox1.Authentication.ClientID := '35454rer657hgo'; (same as acces key)
TMSFNCCloudDropBox1.Authentication.secret := '32378d8a835bx1f';
TMSFNCCloudDropBox1.Authentication.CallBackURL := '';



We are not aware of any issues with refreshing a DropBox access token in TMS FNC Cloud Pack.

As this is a recently added feature in the DropBox API and our focus is on TMS FNC Cloud Pack we haven't yet been able to allocate sufficient development time to implement this in TMS VCL Cloud Pack or TMS FMX Cloud Pack as well.

Somewhat disappointing it isn't available in the VCL Cloud pack. We can use the FNC Cloud pack, but have made changes to the source of the VCL Cloud Pack that we port to each new release. It is specifically about exposing a number of fields that TMS keeps private (why I have no idea). Todate we expose the UID and the email address, we need that for our code. I note the FNC VCL Cloud pack exposes the UID NOT the email address. The code in GetAccountData is very different in FNC VCL Cloud pack:

What is the simplest way in FNC VCL Cloud pack to expose the email address associated with the retrieved Dropbox UID in the GetAccountInfo function call?

I am just trying to do as little changes to the source as is possible.


Too late to edit my post:

I see The FNC Cloud pack makes the REST call in getAccountInfo, but then calls doGetAccountInfo which is pretty much the same as the VCL Cloud Pack getAccountInfo. So I have managed to expose the Email and retrieve it as part of the '.info' properties as in TMSVCLFNCCloudDropbox.Info.Email.



Please note that in the mean time refresh access support has been added to TAdvDropBox.
The update will be available with the next TMS VCL Cloud pack release.

We'll investigate to expose the email address in the account info as well.

Well that's excellent news do u have a eta for this release ?

and did u also manage to fix the crash if file size is larger then 750MB last message from support was that this may be resolved in the next release


The update for TMS VCL Cloud pack was released earlier today.

Unfortunately the issue with downloading large files has not been resolved as this is a technical limitation.

Alternatively I can suggest to use TMS FNC Cloud Pack instead where this issue does not exist.

FNC Cloud pack isn't suitable if you are calling functions from a DLL and in it's own thread because of the callback methodology used. We would rather have used it, but it proved unsuitable.

Having said that, can you confirm that the latest release works out of the box refreshing the tokens or is there something that a programmer would need to do to force a refresh the tokens?

I note, as previous, the token and secret are saved encrypted in the INI file. See my later post, I sem to be missing something.


I'm using the latest version of the TMS VCL Cloud pack. Whilst the software 'appears' to be connected with the short lived token and appears to stay working over an extended period of time, when I stop my application and restart it, the system asks me to (re)Allow access to Dropbox. Previously the credentials were taken from the INI file.

QUESTION Is there anything special I need to do to enable refresh of the short lived tokens. I see no code examples or advice WRT how this should be performed. FWIW, my INI file looks like:


I note that the ACCESS_TOKEN, ACCESS_TOKEN_SECRET, AUTH_TOKEN_SECRET and the REFERSH_TOKEN entries are blank. Is there something I need to do in one of the callbacks (onConnected, onReceivedAuthToken) that sets these up. Everything was working fine until implementation of the Short Lived tokens.

Oh and FWIW, I am using the CloudStorage.Connect method which is supposed to perform all of the necessary authorisations:

This can also be simplified by using the CloudService.Connect function that will perform the
LoadTokens / TestTokens / Refresh all at once and when needed, start a new authentication /
authorization. It is as such important that before calling CloudService.Connect, the application key
and secret is set as well as the location of the token persistence.

Any help/assistance appreciated.


Hi Kevin,

We are not aware of any issues with persisting access token and refresh token for TAdvDropBox.
After a successful connection the ACCESS_TOKEN and REFRESH_TOKENS entries shouldn't be empty.

Can you please make sure that:

  1. SaveTokens is called when the OnConnected event is triggered
  2. The PersistTokens.Key, Location and Section properties are correctly assigned?


  AdvDropBox1.PersistTokens.Key := '.\DTOKENS.INI';
  AdvDropBox1.PersistTokens.Location := plIniFile;
  AdvDropBox1.PersistTokens.Section := 'TOKENS';

Please note that a working sample can be found in the CloudStorageDemo application.

Can you provide more details about the DLL approach you were using?

Hi Pieter,

In a nutshell this is what the DLL does (every two minutes, so there is some time criticallity):

  1. Get a list of shared folder for the current user

  2. Parse the list and for every shared folder:

  3. Create a thread

  4. In each thread check for a folder property using a Dropbox API REST Call (/files/search)

  5. If the folder property is set another REST call to return Folder members (/sharing/list_folder_members)

Note that there can be well in excess of 100 threads running at once. There is no guarantee that the threads will execute in the order in which they were created (this has been proven empirically).

For threading, I'm using the Tmultithread component which allows me to build the list of threads and execute them all in a single statement. It also provides a simple mechanism to communicate results and messages back to the main thread.

If the results are passed back in a callback, I have no idea which thread/Folder is passing back the results, but, and also, executing the subsequent REST call in the thread depends on the results of the first REST call. Providing the results in callbacks just will not work when what I need, whilst in the thread, is linear execution.

Because this function is called every 2 minutes, it needs to complete all threads (and again there can be 100's) well within that two minute target. There is code that will prevent the cycle starting if the previous cycle has not completed, but that is sub-optimal. My timing todate suggests with 70 or so shared folders the process takes around 20 seconds, so there is clearly some finite limit.


Thank you for this detailed analyis. With TMS FNC Cloud Pack, all requests happen asynchronously. We are aware that in some situations (such as small dependent requests) this is not ideal. We have written this down and will see if there is a way to set a property or use a method to execute request synchronously.

Thanks, that would be ideal. Then I would be able to use FNC Cloud pack rather than a platform specific cloud pack.