Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

cris122's avatar
cris122
Explorer | Level 3
9 years ago

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?

3 Replies

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    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's avatar
    cris122
    Explorer | Level 3
    9 years ago

    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's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    9 years ago

    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/auth/index.html#L89

     

    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/auth/index.html#L42

     

    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

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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, Facebook or Instagram.

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!