cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more 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: 

authenticate example using javascript sdk problem

authenticate example using javascript sdk problem

cris122
Explorer | Level 3

When using javascript sdk,

I download dropbox-sdk-js/examples/auth/index.html,

put Dropbox-sdk.min.js, styles.css, utils.js to the same folder,

modify these three file's location in index.html,

<head>
  <title>Dropbox JavaScript SDK</title>
  <link rel="stylesheet" href="styles.css">
  <script src="Dropbox-sdk.min.js"></script>
  <script src="utils.js"></script>
</head>

open index.html will see:

 

after click Authenticate:

 

after click allow:

 

Please help how the javascript sdk get the root file list after authentication?

3 Replies 3

Greg-DB
Dropbox Staff

Hi Cris, based on your first screenshot, it appears you're running the sample from a file:/// URL. These samples are built to run from a local server though, in order to handle the redirect from the app authorizatin flow. Without a local server running, you'll get the error in your last screenshot, as there's no server to handle the redirect.

 

The instructions for running the examples can be found here:

 

https://github.com/dropbox/dropbox-sdk-js/tree/master/examples

 

That covers using `npm start` to run the local server for you. Please try those instructions to get this running.

cris122
Explorer | Level 3

Hi Greg,

 

Thanks for your reply.

I install a new ubuntu 16.04 system on virtualbox and install npm,

I found there is a problem when execute npm start:

 

root@cris-VirtualBox:~/dropbox-sdk-js# npm start

> dropbox@2.5.0 start /root/dropbox-sdk-js
> node examples/server.js

sh: 1: node: not found

command "node" is not found,

 

 

I use

 

root@cris-VirtualBox:~/dropbox-sdk-js# nodejs examples/server.js 

instead and it works well.

 

 

In virtualbox ubuntu open firefox and open http://0.0.0.0:8080 could authenticate and get the root directory file list.

But in windows(both in the same local network) still can't get redirect link

 

click Authentication example

click Authenticate

click Allow

get redirect link

My product is like a wifi router, or nas, user can use browser to open product setting page if via local network, and needs to get dropbox authentication on the setting page.

After authentication, users can sync files or event to dropbox.

I think I could not request users install a web server on their os like windows.

Use a public server is the last resort because it needs additional cost.

Would you please provide some suggestions?

Thank you.

 

 

 

 

Greg-DB
Dropbox Staff

The sample uses a localhost redirect URI by default, but you can change that to be whatever you need. That's done here:

 

https://github.com/dropbox/dropbox-sdk-js/blob/05e8ff949ab352ab5a483507222f17231e3b4d9d/examples/aut...

 

Per the other screenshots, you're using a 1.1.1.58:8080 redirect URI.

 

You'll also need to switch in your own client ID a.k.a. app key:

 

https://github.com/dropbox/dropbox-sdk-js/blob/05e8ff949ab352ab5a483507222f17231e3b4d9d/examples/aut...

 

And make sure you register your redirect URI(s) on your app's page on the App Console:

 

https://www.dropbox.com/developers/apps

 

When implementing your actual app, you can similarly specify whatever redirect URI you want, as long as you pre-register it on the App Console.

Need more support?
Who's talking

Top contributors to this post

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