cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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
Collaborator | Level 9
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

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.1
Collaborator | Level 9
Go to solution

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

Jon B.1
Collaborator | Level 9
Go to solution

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

Greg-DB
Dropbox Staff
Go to solution

Yes, that's correct.

Need more support?