olxj6q
Last Updated: July 18, 2019
·
1.049K
· Khor

How to Use OAuth to Get File List from Dropbox

Goal

We wanted to figure out the easiest way to use OAuth to get file list from Dropbox on behalf of a Dropbox user using Javascript. Here is how we did it with OAuth.io.

Code Snippet

Try this snippet. Once you log in with your Dropbox account it will get the list of files in your account. Feel free to tweak it to get file list from different folders, etc.

https://jsfiddle.net/p187m5ur/6/

Code Explanation

HTML

<a id="dropbox-button" class="btn btn-block btn-social btn-dropbox">
  <i class="fa"></i> Get file list
</a>

CSS

None

Javascript

var params = {
  "path": ""
};
$('#dropbox-button').on('click', function() {
  // Initialize with your OAuth.io app public key
  OAuth.initialize('OAUTH_IO_PUBLIC_KEY');
  // Use popup for oauth
  // Alternative is redirect
  OAuth.popup('dropbox').then(provider => {
    console.log('provider:', provider);
    alert("You can check Dropbox provider object in browser console.");

    provider.post({
      url: "/files/list_folder",
      data: JSON.stringify(params),
      headers: {
         "Content-Type": "application/json"
      }
    }).then(data =>             {
      console.log('Files:', data);
      alert("You can find file list in browser console");
    });
  });
})

External Requirements

This Javascript code has external requirements:

Step-by-step Guide

Here is a summary of the steps to create this social button to get file list from Dropbox on a user's behalf using OAuth2.

  1. Create a Dropbox account, if you do not have one
  2. Create an app on Dropbox using this simple step-by-step guide
  3. Copy your Dropbox app client id and client secret
  4. Signup for OAuth.io account
  5. Link your Dropbox app with OAuth.io by pasting your Dropbox app client id and client secret into OAuth.io
  6. Copy the OAuth javascript snippet (https://jsfiddle.net/p187m5ur/6/) on to your web page

References

Use OAuth to get file list from Dropbox: https://tome.oauth.io/providers/dropbox/get-file-list

8 Responses
Add your response

33120

I will impart the post to my companions. I'm extremely awed with your article, such incredible and useful learning you specified here. Best dissertation writing service is recognized by their reliability and high exceptional merchandise. The identical applies to top dissertation writers. There is no way a pinnacle dissertation writing service can host writers who aren't certified academically and professionally. https://www.dissertationcapital.com/

about 2 months ago ·
33164

Get the easy Steps to install and activate McAfee, enter your 25-digit alphanumaric product key at mcafee.com/activate for mcafee activate.
visit- https://mmcafeecomactivate.com/

about 2 months ago ·
33188

you can find the solution for this problem on Gomax TV Live App http://www.gomaxlivetv.com/

about 1 month ago ·
34311

Informative Speech Essays
Our Pay for informative speech essays online customer access our dissertation services knowing that they are assured of the best quality essay lest they get their money back.
https://www.meldaresearch.com/77informative-speech/

18 days ago ·
34312

Informative Speech Essays
Our Pay for informative speech essays online customer access our dissertation services knowing that they are assured of the best quality essay lest they get their money back.
https://www.meldaresearch.com/77informative-speech/

18 days ago ·
34338

Basically, the technology essay replicates the structure and the main principles of a standard essay with a few peculiarities of its own.
We offer you to study the procedure of writing the http://thesisacknowledgement.net/ on a concrete example. Let's suggest your topic sounds something like "Influence of Modern Technology on Society". The goal of your custom essay is to describe and discuss complicated relations between technology and society. You are to clarify how some particular technology affects people. You are free to illustrate the influence on any sphere of modern life that your technology has affected most.

First of all, people describe technology as ever-changing. Today new innovations become obsolete fast. People have become increasingly competitive and every year, new ideas and technologies are released to challenge the ones in the market. In a few months, a piece of technology can be released to the market and almost immediately rival companies will as well release theirs. Technological ideas keep getting unleashed as the world becomes more involved in exploring and utilizing the resources nature provides. Nothing seems to survive this fast paced world and unless one maintains the pace and moves with the wave, they get left behind..Read more about technology at http://thesisacknowledgement.net/

17 days ago ·
34391

Our Pay for educational discourse expositions online client get to our paper administrations realizing that they are guaranteed of the best quality article in case they recover their cash. https://laborday2019s.com

10 days ago ·
34490

I love what you guys tend to be up too. This type of clever work and reporting!
Keep up the amazing works guys I’ve included you guys to our blogroll.
https://light-novel.online/

2 days ago ·