Authorization not remembered

I'm using XE5, win32. I'm having a problem where occasionally the control will prompt for authorization when logging in even when tokens are saved from a previous login. This occurs within the same hour.

For example:
Start the app, connect to box, get prompted for login, use the app. Close app.
Start the app, connect to box, use the app. Everything is fine. Close app.
Start the app, connect to box, get prompted for login again. It should remember it at that point.

It doesn't happen every time though. Have you seen any issues with this?


We are not aware of any issues with
Can you please make sure the tokens are saved to a file correctly?
Does the issue also occur with the CloudStorage demo app?

The tokens get saved properly. I thought that maybe they didn't like all being in one ini file, so I separated it so they all use different ini files, but the problem continues.

Yesterday I logged into then exited the app.
This morning I logged into (did not need to authorize) and then exited the app.
I immediately re-entered the app and I logged into and was prompted for authorization. While the auth form was showing, I looked at the ini file and all the entries had been cleared.

This code works for DropBox, Box,net, and SkyDrive. is the only one that seems to have a problem, although I just implemented SkyDrive this morning.

I'll continue to keep an eye on it and see what comes up with the logging routines I just added.

Here's my Login Routine:
  AddLogItem('Testing Tokens...');
  bAccessible := CloudStorage.TestTokens;
  if not bAccessible then begin
    AddLogItem('Tokens failed test, Refreshing Access.');
    bAccessible := CloudStorage.RefreshAccess;
  if not bAccessible then begin
    AddLogItem('Token refresh failed, Prompting for Authorization.');
  else begin
    AddLogItem('Access Refreshed, Doing Remote Refresh...');

and the tokens event:
procedure TfrmCCPlacesViewCloud.CloudControlsReceivedAccessToken(Sender: TObject);
  cs: TCloudStorageWin;
  Authenticated := true;
  AddLogItem('Access Tokens Received, Doing Remote Refresh...');
  if (Sender is TCloudStorage) then begin
    cs := Sender as TCloudStorageWin;

RemoteRefresh does a GetDriveInfo, Fills the Tree, then loads a listview of items in the selected tree node. (my tree is hidden).

The only reason I can see for this is that OnReceivedAccessToken is triggered erratically, i.e. when there is not really an access token obtained. OnReceivedAccessToken should only come after having called DoAuth. Can you perhaps add a breakpoint in OnReceivedAccessToken and verify that this event isn't triggered when you had not called DoAuth before?

Ok, I just had it happen again, here's my logging:
Testing Tokens...
Tokens failed test, Refreshing Access.
Token refresh failed, Prompting for Authorization.
Access Tokens Received, Doing Remote Refresh...

I've tested this here over 10 times but couldn't see a problem. Are you sure your app always correctly can load its access token & refresh token? Where do you persist these?

If a problem remains, please set AdvBoxNetDrive.Logging = true and send the log file via direct email to support so we can inspect what exactly happened.

I'm still having issues with this, so I'm back working on it. I have a single form that connects to Dropbox, OneDrive, and The code all uses the same method for saving and extracting the token ini file from a zip file. All of the services work except for box.

I can reproduce this with the StorageDemo. I hadn't run the demo in quite a few days. Today, I simply ran the compiled demo, Selected Box, clicked Connect, and it let me into box without having to authorize, so the tokens must have been ok from the previous time it ran. I simply clicked Disconnect and then Connect and I had to re-authorize.

I re-ran the demo again and it works fine. I'll check it tomorrow and see if it does it again.

If it makes any difference, I don't ever log into box in the standalone Internet Explorer.