cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can you help me understand and use WebHooks?

Can you help me understand and use WebHooks?

Infarch
Explorer | Level 4
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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.

Infarch
Explorer | Level 4
Go to solution

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?

Greg-DB
Dropbox Staff
Go to solution

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. 

Infarch
Explorer | Level 4
Go to solution

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.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Infarch Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?