How to take the step from auth example to getting a "re-useable access token"
Hi,
This is not a bug, but a request for an extension to the auth example (https://github.com/dropbox/dropbox-sdk-js/tree/master/examples/typescript/auth) .
The Auth documentation here: https://www.dropbox.com/developers/reference/oauth-guide mentions that for web applications I should be using the authorization code that I can get by using the auth example (I use the TypeScript one) in order to get a re-useable access token, but I can't for the life of me figure out how to do this.
Am I misunderstanding things, and I should be saving and re-using the authorization code itself? If not; is it possible to please extend the auth example to requesting this token?
Thanks!
The "authorization code" itself is a temporary, single-use string, so you wouldn't store and re-use it. You would exchange it once for an "access token". The access token would then be stored and re-used.
Anyway, the OAuth guide you're referring to is written more for server-side apps, using the "code" flow (described int he paragraph above). Client-side apps, such as apps running in JavaScript in the user's browser, can instead use the "token" flow, which doesn't make use of an "authorization code" at all. This JavaScript SDK only implements the token flow.
Since this SDK only uses the token flow, you can see in the auth example where it gets the access token directly (without exchanging an authorization code) here:
https://github.com/dropbox/dropbox-sdk-js/blob/master/examples/typescript/auth/auth.ts#L44
Ah!
So in the typescript auth example that is the access token that I can then save indefinitely for getting access to the dropbox account?
That's great!
Thanks
Yes, that's correct.
(Also, note that while the access token doesn't expire, users can manually revoke them of course.)