cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Back again with another edition of 'How we use Dropbox', so find out how Ross uses Dropbox to answer some new house questions here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: Saving and restoring a short-term token

Saving and restoring a short-term token

Jon B.1
Helpful | Level 6

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?

1 Accepted Solution

Accepted Solutions

Re: Saving and restoring a short-term token

Greg-DB
Dropboxer

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.

View solution in original post

4 Replies 4

Re: Saving and restoring a short-term token

Greg-DB
Dropboxer

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.

View solution in original post

Re: Saving and restoring a short-term token

Jon B.1
Helpful | Level 6

Brilliant!  Nice to know I was overthinking things...

Re: Saving and restoring a short-term token

Jon B.1
Helpful | Level 6

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...

Re: Saving and restoring a short-term token

Greg-DB
Dropboxer

Yes, that's correct.

Need more support?