cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
If you’ve changed your email address, now's the perfect time to update it on your Dropbox account and we’re here to help! Learn more 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: Tokens only valid for 4 hours from app console

Re: Tokens only valid for 4 hours from app console

gcarl
Explorer | Level 4

Dear community, dear GregDB,

 

is there a possibility in the SDK for swift to refresh the token in the background without manual involvement of the app user? Although my app is configured to provide a permanent token (!) the connection is interrupted after a certain while and the users of my app have to repeat the approval manually in the Dropbox application which leads to a lot of annoyance.

 

Before accessing dropbox I check the connectivity as follows:

 

 

if let client = DropboxClientsManager.authorizedClient {
        client.files.listFolder(path: rootPfad).response {response, error in
            if let _ = error {
                ...
            } else {
                ...
            }
        }
    } else {
        connectDropbox(withRequest: Dropboxrequest.connect)
    }

 

 

and if there is no authorizedClient then I reconnect as follows:

 

 

func connectDropbox(withRequest request: Dropboxrequest) {
        dropboxrequest = request
        let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["files.content.write", "files.content.read", "account_info.read"], includeGrantedScopes: true)
            DropboxClientsManager.authorizeFromControllerV2(
                UIApplication.shared,
                controller: self,
                loadingStatusDelegate: nil,
                openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) },
                scopeRequest: scopeRequest
            )
    }

 

 

1 Reply 1

Greg-DB
Dropbox Staff

Yes, as long as you implement the authorization flow as shown, the SwiftyDropbox SDK will automatically handle the refresh process for you in the background, without any further manual user interaction required.

 

If something isn't working as expected, please show the steps you're following when seeing the issue and the unexpected error/output.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?