Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
Alex_Ch
3 years agoHelpful | Level 5
How can i get an acces token without a login?
why am I using Dropbox? I´m developing a project with react. It's pretty simple, just a form where ussers send a pdf file. The thing I want to do is just that the ussers send their file and its up...
- 3 years ago
Hi Alex_Ch,
Since you want to access your own account (not user's accounts), the best way would be to implement the entire communication to your Dropbox account (or the communication management, at least) on your server side. In such a way you can use pre-generated refresh token usable to refresh your access token (generation whenever needed - something performed automatically when official SDK is in use). There is no way access token to be generated completely without user confirmation (the your confirmation in particular case - your account is the target), but once refresh token is generated you can use it without further interaction from your side or your site's users.
One scenario is on post the pdf, it flows to your site and next from your site to Dropbox (i.e. your site behave like a proxy). Other scenario is on user intent to post, on your site a temporary upload link to be generated and the pdf to be uploaded directly to Dropbox (without passing through your site) using this link. In the both cases you don't expose any credentials to the user's browser, something that should be followed (or is advisable, at least).
Hope this gives direction.
Здравко
3 years agoLegendary | Level 20
Alex_Ch wrote:... Is there another way to get the authorization code without that login? ...
No, it's not.
Alex_Ch wrote:... The app only needs access to my own account
Ok, so you need to perform OAuth (including receiving access code) once, as Greg said, and no more. Once you have refresh token you don't need to open any login screen. The refresh token, application key, and (optionally - becomes mandatory for no PKCE) application secret are enough for automatic access token regeneration without any further user interaction (including interaction to you).
Alex_Ch
3 years agoHelpful | Level 5
Ok, I think I finally got it.
Just one more thing. In the SDK for javascript, I tried to use the command "refreshAccessToken", but it doesn´t read the scopes, I always get the "Scope must be an array of strings" error, even when I define the array in the property.
Where could I find an example of that command? I think I´m using the syntax wrong
- Greg-DB3 years ago
Dropbox Community Moderator
Alex_Ch You do not need call refreshAccessToken yourself, unless you need to retrieve a client with a sub-set of the authorized scopes. The SDK will automatically perform the refresh process for you automatically for the currently authorized scopes without you calling refreshAccessToken in your own code.
If you do want to call refreshAccessToken explicitly though, you could do so like this:
dbx.auth.refreshAccessToken() .then(function() { // ... }) .catch(function(error) { console.error(error); });To call refreshAccessToken with a specific set of scopes, pass in a list like this:
dbx.auth.refreshAccessToken(["account_info.read", "sharing.read"]) .then(function() { // ... }) .catch(function(error) { console.error(error); });
About 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!