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
Jon B.1
4 years agoCollaborator | Level 9
Saving and restoring a short-term token
Hi -- still trying to un-mothball and update an old SwiftyDropbox-based app, and migrate it to short-life tokens. The standard auth process is basically working now, but I'm wondering if I can preserve more of its old behaviour.
Previously, I saved the long-life token to a plist file, and if it was still valid on app re-start it would simply create the client from the token:
client = DropboxClient(accessToken : token)
What's the equivalent with short-life tokens? Presumably the access token would still work if they quit and relaunch the app within four hours... but is there any way to preserve the refresh token as well, so that they don't then have to re-authorise when that token expires? Would that require implementing a new provider derived from ShortLivedAccessTokenProvider? And if so how would I get the refresh token out of the client to save it in the first place?
If you use authorizeFromControllerV2, the SwiftyDropbox SDK will automatically store and use the refresh token for you. You should just use authorizedClient to get the client and the SDK will take care of the refresh process.
- Greg-DBDropbox Staff
If you use authorizeFromControllerV2, the SwiftyDropbox SDK will automatically store and use the refresh token for you. You should just use authorizedClient to get the client and the SDK will take care of the refresh process.
- Jon B.1Collaborator | Level 9
Brilliant! Nice to know I was overthinking things...
- Jon B.1Collaborator | Level 9
Just to confirm, though: I'm aware that authorizedClient maintains and refreshes the same tokens while the app is running. But you're saying that if I quit and relaunch the app, authorizedClient persists the tokens and is still valid by default? If so, I'm a very happy man...
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,880 PostsLatest Activity: 25 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!