You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
chainsbomb
2 years agoExplorer | Level 4
Solution for Dropbox API where I have a non-standard setup.
My app is single-page server-side javascript/HTML, but I don't use Node. This seems to mean that I can't just import {Dropbox} from 'dropbox' I am able to access use the chooser and saver by usin...
Greg-DB
Dropbox Staff
chainsbomb As Здравко said, it's not necessary to use an SDK to access the Dropbox API, as you can construct the network requests directly.
It is worth nothing though that the official Dropbox API v2 JavaScript SDK supports both back-end Node and front-end browser JavaScript environments. So, you can use a <script> tag to import the Dropbox API v2 JavaScript SDK into browser JavaScript, from a CDN of your choice. Dropbox doesn't require or endorse any particular CDN, but for example, the Dropbox API v2 JavaScript SDK is available on cdnjs.
djschoch
8 months agoExplorer | Level 3
Hi Greg-DB,
Can you provide a simple example of what I need to do in my JavaScript to use the Dropbox SDK using a CDN? I have the script statement in my HTML header, but I don't know how to access it in my JS. One example I found using the "import" statement, but apparently that doesn't work unless I have the SDK installed in my project. Your help is greatly appreciated!
-Dan-
- Greg-DB8 months agoDropbox Staff
djschoch The script tag in the examples load the SDK from a local copy, but if you want to use the Dropbox JavaScript SDK in browser JavaScript and load it from a CDN, you should be able to do so like this, and access the 'Dropbox' object:
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/dropbox.js/10.34.0/Dropbox-sdk.min.js"></script> <script type="text/javascript"> console.log(Dropbox); </script> </head> <body> </body> </html>
Here I've just logged the object as a way to check it is available. As long as that is loaded successfully, you should then be able to use that 'Dropbox' object like in the examples here, for instance.
- djschoch8 months agoExplorer | Level 3
Greg-DB,
Thank you SO MUCH for your help. This is exactly the jumpstart I needed. I fumbled a bit, but I now have a basic call working successfully. Your help is very much appreciated.
One last question (this is probably in the documentation somewhere; I apologize for being lazy at the moment): Can you show how to get a current access token, based on my appKey (and appSecret?)? Also, how long is the access token valid?
THANKS again,
-Dan-
- Greg-DB8 months agoDropbox Staff
djschoch Check out the example here to see how to process the OAuth app authorization flow with the Dropbox JavaScript SDK to get an access token.
Dropbox issues short-lived access tokens which are valid for a few hours. You can get the exact expiration information from the API when it returns the access token, e.g., it would be available in 'response.result.expires_in' in the getAccessTokenFromCode callback in that example.
You can find more information on the authorization functionality in the OAuth Guide and authorization documentation.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,888 PostsLatest Activity: 59 minutes agoIf 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!