Comments (7)
Dropbox is no longer offering the option for creating new long-lived access tokens. Dropbox is now issuing short-lived access tokens (and optional refresh tokens) instead of long-lived access tokens. You can find more information on this migration here.
Apps can still get long-term access by requesting "offline" access though, in which case the app receives a "refresh token" that can be used to retrieve new short-lived access tokens as needed, without further manual user intervention. You can find more information in the OAuth Guide and authorization documentation. There's a basic outline of processing this flow in this blog post which may serve as a useful example. Use of a redirect URI is not required, whether or not you're requesting a refresh token.
For examples of implementing this with the Dropbox JavaScript SDK, please refer to the examples included in the "examples" folder in the SDK. As long as you set the app key (a.k.a. client ID) and refresh token, like shown in this example for the JavaScript SDK, the SDK will actually handle refresh process for you automatically. The SDK will automatically catch expired access token errors and call the API to get a new short-lived access token when needed. Refresh tokens don't expire (though they can be revoked on demand), so it doesn't need to be replaced/updated each time; you can re-use the same refresh token repeatedly. So, if this is only for your own account, you would only need to get a refresh token for your own account once and could re-use that.
from dropbox-sdk-js.
Thanks, I didn't realize that refresh tokens didn't expire <3
from dropbox-sdk-js.
@greg-db I'm still having issues. Even though I provided both an access token and refresh token, I keep getting "expired_access_token". It works initially, but stops after a bit (I haven't measured how long)
from dropbox-sdk-js.
Please share the code you're running that isn't working as expected so we can take a look. Please redact the app secret and token values themselves though.
from dropbox-sdk-js.
const dbx = new Dropbox({
accessToken: '...',
refreshToken: '...',
pathRoot: JSON.stringify({ '.tag': 'root', root: '...' }),
selectUser: '...'
});
export const myFunc = async () => {
// ...
const { result } = await dbx.filesListFolder({ path, recursive: false });
// ...
}
from dropbox-sdk-js.
The refresh process requires the app key (a.k.a. client ID), and if the refresh token wasn't retrieved using PKCE, the app secret (a.k.a. client secret) as well. So, when constructing the Dropbox
object, make sure you supply the clientId
, and if needed clientSecret
.
from dropbox-sdk-js.
Thanks!
from dropbox-sdk-js.
Related Issues (20)
- Autorename not working HOT 1
- Can I use this API without npm? HOT 1
- No error when connection dropped, causing uploads to hang forever. HOT 2
- missing extension (for esm) HOT 3
- Example does not work HOT 2
- web version of the sdk should use the browser crypto api HOT 1
- DropboxAuth.getAuthenticationUrl returns incorrect type HOT 1
- Fix TS links in the readme HOT 1
- Incorrect typescript definitions HOT 1
- Get Upload progress HOT 1
- built-in `fetch` in node 20 issues error HOT 6
- nextjs upload file Dropbox API HOT 3
- this.fetch is not a function error received HOT 3
- V10.34.0 _utils.isBrowserEnv not working in all cases. HOT 1
- res.buffer is not a function in bun HOT 2
- fileBinary not present in TS definitions for filesDownload HOT 1
- Change deprecated .buffer() to .arrayBuffer() HOT 3
- Typescript Types Missing HOT 1
- Typescript types missing "team_member_root" from NamespaceType definition HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropbox-sdk-js.