Announcements
Can you spare 5 minutes to help us improve our online support experience? Get involved!

Can you help me understand and use WebHooks?

Explorer | Level 4

Hi all!

I experience problem with understanding and using web hooks. Hope that someone can help me. So, let me explain the case.

I use Chooser on my site, configured for getting 'preview' links. I send these links to the server, which downloads and stores files. I want to extend this functionality and monitor changes in files at user side. When a new version is uploaded, my site automatically gets this version.

That could be implemented by keeping the link and asking API with some interval. But I don't want to spam API by a large number of request. So the idea is to use web hooks. I've registered a hook for my application. But it was called only once, during verification. Chosing of files in Chooser does not fire events.

I think that my way is wrong, but cannot figure out how to achieve my goal. May be someone could help me?

1 Accepted solution

Accepted Solutions

Re: WebHooks

Dropboxer

Dropbox webhooks are only sent for changes in the accounts "connected" or "linked" to your app. That is, accounts for users who went through the OAuth app authorization flow to authorize your app to access their accounts.

When you use the Dropbox Chooser, users can share links to specific files/folders with your app, without fully connecting their accounts to your app. The Chooser lets the user just choose which specific item(s) to supply to your app, without going through the full OAuth app authorization. Dropbox doesn't offer a way to get webhook notifications for changes to shared links just from having the shared links.

That being the case, you won't get any webhook notifications for users who just used the Chooser for your app. If you want webhook notifications, you'll need to prompt them to authorize your app. You can find more information on how that works in the OAuth Guide and the authorization documentation.

Reply
Loading...
4 Replies

Re: WebHooks

Dropboxer

Dropbox webhooks are only sent for changes in the accounts "connected" or "linked" to your app. That is, accounts for users who went through the OAuth app authorization flow to authorize your app to access their accounts.

When you use the Dropbox Chooser, users can share links to specific files/folders with your app, without fully connecting their accounts to your app. The Chooser lets the user just choose which specific item(s) to supply to your app, without going through the full OAuth app authorization. Dropbox doesn't offer a way to get webhook notifications for changes to shared links just from having the shared links.

That being the case, you won't get any webhook notifications for users who just used the Chooser for your app. If you want webhook notifications, you'll need to prompt them to authorize your app. You can find more information on how that works in the OAuth Guide and the authorization documentation.

Reply
Loading...

Re: WebHooks

Explorer | Level 4

Thank you for the reply!

Trying to follow your suggestion, I've changed my code a bit. Now the workflow is:

a) I redirect a user to authorization endpoint:

https://www.dropbox.com/oauth2/authorize?client_id=<my_app_key>&response_type=code&redirect_uri=<my_...>

b) <my_callback_url> gets <code> from dropbox.

c) I ask dropbox again for a token, posting the following values:

my $endpoint = 'https://api.dropbox.com/oauth2/token';
my $post_parameters = {
code => $code,
grant_type => 'authorization_code',
client_id => $AppKey,

redirect_uri=>$uri,
client_secret => $AppSecret
};

As the result I get a token which allows to download files not only by shared url, but also by ID.

But there still is a problem with hooks: I do not receive calls from Dropbox when I (or other test users) change files in personal account or upload new ones. May be I have  to start monitoring by some explicit command?

Reply
Loading...

Re: WebHooks

Dropboxer

What you've described here is the correct way to connect a user if you want webhook notifications for changes in their account. You don't need to send any other explicit command to start monitoring. 

If you're still not able to receive the webhook notifications, please open an API ticket with the details (the app name, the webhook URI, and the relevant user ID) so we can check on this for you. 

Reply
Loading...

Re: WebHooks

Explorer | Level 4

It really works! There was a problem on my server receiving notifications, but I did not notice that at time due to some latency of application console. So the correct authorization workflow is enough for receiving hook requests.

Reply
Loading...
API Support

Have a question? Our Dropbox Community is here to help you find an answer!
You won’t have to wait too long for a reply, but why not learn more about the Community while you’re here.

Not the right discussion for you? Find out what else our Community has to say about API Support.

Or, search our Help Center for even more.

Who's talking
Top contributors to this post