We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
gcarl
4 years agoExplorer | Level 4
Re: Tokens only valid for 4 hours from app console
Dear greg-DB,
sorry, but I have to come back to this topic again, since I couldn't solve it in the recent weeks despite all these valuable hints in this forum and the description for the Swift ...
Greg-DB
Dropbox Community Moderator
4 years agoThere is a refreshAccessToken method, but you don't need to call that. (That's used internally, or if you want to switch to a smaller subset of scopes.) The SDK automatically performs the normal refresh process for you.
It doesn't sound like that's the issue anyway though, as the local client wouldn't get set to nil if the access token expires. The server would just return an error when an expired access token is used. Also, it doesn't seem like expiration is the issue since you're seeing this occur sooner than four hours after authorization.
Are you calling anything like unlinkClients, resetClients, or clearStoredAccessToken(s)?
gcarl
4 years agoExplorer | Level 4
Dear greg-DB,
thanks for your quick replies - highly appreciated.
No, I'm not using unlinkClients, resetClients, or clearStoredAccessToken(s) or something like it. As quoted above, I only do the setup with the DropboxClientsManager.setupWithAppKey() in appDelegate und authorize with the DropboxClientsManager.authorizeFromControllerV2(). After it I only do read and write tasks - all checked with
if let client = DropboxClientsManager.authorizedClient {... }where sometimes the nil-value is returned, in which cases then the reconnection is initiated.
In which cases turns the DropboxClientsManager.authorizedClient to nil? Do I have to handle it differently, when it is nil? Currently I'm calling the DropboxClientsManager.authorizeFromControllerV2() in these cases.
- Greg-DB4 years ago
Dropbox Community Moderator
The authorizedClient should only be nil if the clients were reset, or if after a relaunch the SDK wasn't able to retrieve the token from the Keychain. There isn't anything else you need to be doing to keep the authorizedClient available. Calling authorizeFromControllerV2 when you don't have an authorizedClient and need to connect to an account is the right procedure. Seeing authorizedClient automatically revert to nil is just unexpected.
Anyway, I don't see anything you're doing wrong here that should cause this, and I can't reproduce the issue here myself. Apologies for the bother, but would you be able to share a small sample project that reproduces the issue so we can investigate here? Thanks in advance!
- gcarl4 years agoExplorer | Level 4Dear Greg-db,
would it be helpful if I send you a promocode for the AppStore for my app I‘m facing this issue via e-mail?- Greg-DB4 years ago
Dropbox Community Moderator
That may not be helpful as we wouldn't be able to inspect or debug the code directly.
I've put together a small sample project using the code snippets you provided here, just filling in the gaps as necessary. It doesn't reproduce the issue for me. (It retains the authorizedClient and can successfully make calls even after more than four hours after authorization.) Could you try it though and see if produces the issue for you?
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!