One month down in 2025: How are your resolutions coming along? Check out how to get back on track here.
Forum Discussion
cris122
9 years agoExplorer | Level 3
authenticate example using javascript sdk problem
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?
- 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.
- cris122Explorer | 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:
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:
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 2 days ago
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!