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?

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox 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's avatar
      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.

       

       

       

       

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,950 PostsLatest Activity: 2 days ago
351 Following

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!