EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Dropbox sample doesn't connect

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#30925
Posted: 10/09/2014 04:09:51
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Hello,

I've just updated to CloudBlackbox 12, and immediately tried to use the Dropbox sample app, but without success (I remember the previous one worked).

Using the same data I'm perfectly able to connect with another application.

I haven't changed anything in the sample app.

The error reported is: "HTTP request failed with code 401, message is Unauthorized".

---

I need another information to use the cloud components: after the first authentication using the web browser, how to store the tokens and reuse them for a scheduled transfer, without needing to authenticate again using the browser ?
#30926
Posted: 10/09/2014 04:25:10
by Alexander Ionov (EldoS Corp.)

Thank you for contacting us.

The problem with "Unauthorized" error report already solved. The changes will be available in the next SecureBlackbox build which is expected this weekend.

Quote
ntr1 wrote:
I need another information to use the cloud components: after the first authentication using the web browser, how to store the tokens and reuse them for a scheduled transfer, without needing to authenticate again using the browser ?

You have to save values of AuthToken and AuthTokenSecret properties and restore them later. But these values have an unknown expiration period. So when they expire and you get "Unauthorized" error you need to ask the user to authenticate again using the browser and then save new values of AuthToken and AuthTokenSecret properties.


--
Best regards,
Alexander Ionov
#30927
Posted: 10/09/2014 05:37:32
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Hello,

thank you for getting back to me so quickly.

I know the token expiration depends on the provider (if I remeber correctly, Box tokens expire very fast, so it's practically unusable in an automated way).

I noticed now the OneDrive and GoogleDrive samples store the token into the INI file. So they don't need another authentication with web browser. Good.
However, the Dropbox sample doesn't store the token. Why ?

---

Apart from this, I found some other issues in the Google Drive sample. It gives an error after connection (but in this case the program continues and shows the files) and it isn't able to create folders.

Finally, both the sample apps are very slow the first time they load the authentication page. What could be the reason ?

I've attached the error messages.


Thank you


#30928
Posted: 10/09/2014 06:01:58
by Alexander Ionov (EldoS Corp.)

Quote
ntr1 wrote:
I know the token expiration depends on the provider (if I remeber correctly, Box tokens expire very fast, so it's practically unusable in an automated way).

I noticed now the OneDrive and GoogleDrive samples store the token into the INI file. So they don't need another authentication with web browser. Good. However, the Dropbox sample doesn't store the token. Why ?

Box, Google Drive and OneDrive use OAuth 2.0 for authentication. They all support a so called token refreshing technique. I.e. if you have a refresh token stored, then you can get a new access token which is used to access info on these clouds. The samples you mentioned store refresh tokens in their INI files, not access tokens.
By now, our Dropbox component supports only OAuth 1.0 authentication protocol. It is completely different protocol with another request-response flow. This protocol does not provide token refreshing at all so it requires the user to authenticate in the web browser each time when access to his/her data is needed.
Now we added OAuth 2.0 support for Dropbox also but unfortunatelly this cloud does not provide a refresh token, so this technique cannot be used to update access tokens.

Quote
ntr1 wrote:
Apart from this, I found some other issues in the Google Drive sample. It gives an error after connection (but in this case the program continues and shows the files) and it isn't able to create folders.

This problem seems to be already solved also. The changes will be available in the next SecureBlackbox build.

Quote
ntr1 wrote:
Finally, both the sample apps are very slow the first time they load the authentication page. What could be the reason ?

Authentication pages are actually loaded by the embedded web browser control provided by Internet Explorer. Unfortunatelly we have nothing to do with it in order to speed up this process.


--
Best regards,
Alexander Ionov
#30957
Posted: 10/10/2014 09:06:41
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Hello,

Quote
<<Now we added OAuth 2.0 support for Dropbox also but unfortunatelly this cloud does not provide a refresh token, so this technique cannot be used to update access tokens.>>


Actually I'm sure it can be done. In fact, we're coming to your components from other Delphi components (TMS), that have a lot of limitations (for example, they cannot send to Dropbox files bigger than 150 MB). However, tokens can be stored and reused, without needing to reauthenticate with browser. We're already doing that in our application. So it should be made also by your component.
#30960
Posted: 10/10/2014 09:22:52
by Alexander Ionov (EldoS Corp.)

We've already explained above what to save and restore for OAuth 1.0 which is supported by our Dropbox access component right now.

For OAuth 2.0 (which is coming out in the next SecureBlackbox build) you can instead save and restore value of the AccessToken property but we don't know how long each access token is valid. And when the current access token expires, there is no way to get another one without having the user to login in the web browser again. At least we don't know such way - it's not described in the Dropbox documentation at https://www.dropbox.com/developers/cor...-authorize


--
Best regards,
Alexander Ionov
#30962
Posted: 10/10/2014 09:38:28
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Thank you for your answer.

I'm happy to know in the next build there will be the possibility to save the access token, hoping it will be kept valid by Dropbox for a reasonable time.

I hope there will be an updated sample project to show how to do that.


By the way, I've just posted a ticket for a license issue. Can you help me also on that ?
#30963
Posted: 10/10/2014 10:05:18
by Alexander Ionov (EldoS Corp.)

Quote
ntr1 wrote:
I hope there will be an updated sample project to show how to do that.

We didn't change the sample for Dropbox to use OAuth 2.0 because we can't find a way to use the embedded web browser control for authentication. Unfortunatelly, Microsoft has changed something in IE security settings and now the embedded web brower cannot connect to localhost. This does not allow the sample program to get an access token from Dropbox server.
If IE is used as an external web browser, it shows a message box and requires the user to allow the browser to connect to localhost.

Quote
ntr1 wrote:
By the way, I've just posted a ticket for a license issue. Can you help me also on that ?

Questions about licenses are answered by our Sales department. I believe they'll answer your question shortly.


--
Best regards,
Alexander Ionov
#30964
Posted: 10/10/2014 10:53:26
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Quote
Unfortunatelly, Microsoft has changed something in IE security settings and now the embedded web brower cannot connect to localhost.


This can be solved as well. As you said, you can pass to Dropbox API call a "callback" URL (&oauth_callback=), but you're not obligated to use localhost: you can pass an URL on any website. In fact, we currently use this workaround with our current component. You can add a property that allow users to specify a custom callback url, and you simply have to intercept that URL.
#30971
Posted: 10/13/2014 08:44:05
by ntr1 (Standard support level)
Joined: 02/05/2014
Posts: 73

Any confirmation about that ?

I've just check my code and you're right. It's still using the OAuth 1.0.

However, I've just read the Dropbox documentation (https://www.dropbox.com/developers/blog/45/using-oauth-20-with-the-core-api) and saw there is still the possibility to pass a "redirect uri" parameter. So the workaround of passing a custom URL (and NOT localhost) can perfectly work.

Thank you
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

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