EldoS | Feel safer!

Software components for data protection, secure storage and transfer

DropBox, OAuth2 and access token

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
Posted: 03/03/2015 08:41:50
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 165


I am attempting to create and reuse a long-lived access token for DropBox through OAuth2. I'm using the dropbox component with Delphi XE5 (with the latest available version of SBB12: 12.0.266, at time of this writing).

I have:

1/ Successfully modified the sample to use OAuth2 instead of OAuth.
2/ Sucessfully logged in a first time through the StartAuthorization2 and CompleteAuthorization2 calls
3/ Saved AppToken, AppTokenSecret and AccessToken.

When I restart the authentication flow, I reset all of the above parameters to their saved values. Unfortunatley, that raises an exception in CompleteAuthorization2

      URL := Dropbox.StartAuthorization2(LocalEndpoint);
      if (URL <> '') then
        if not TfrmLogin.Execute(URL, LocalEndpoint, DenyURL, AllowedbaseURL, Code) then
      Dropbox.CompleteAuthorization2(Code); // exception is raised here

Project DropboxDemo.exe raised exception class EElDropboxDataStorageError with message 'Authorization has not been started; call StartAuthorization or StartAuthorization2 method first'.

What am I doing wrong ?
Posted: 03/03/2015 09:07:23
by Alexander Ionov (EldoS Corp.)

Thank you for contacting us.

1. If you use OAuth2, you don't need to save and restore AppToken and AppTokenSecret because they are used by OAuth1.

2. You don't need to call CompleteAuthorization2 if StartAuthorization2 returned an empty string.

Best regards,
Alexander Ionov
Posted: 03/03/2015 09:13:46
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 165

Perfect! It works like a charm.

Thanks a lot.




Topic viewed 2260 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!