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.
#32445
Posted: 03/03/2015 08:41:50
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

Hello,

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



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


Quote
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 ?
#32446
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
#32447
Posted: 03/03/2015 09:13:46
by Stephane Grobety (Priority Standard support level)
Joined: 04/18/2006
Posts: 170

Perfect! It works like a charm.

Thanks a lot.

St├ęphane

Reply

Statistics

Topic viewed 2332 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!