Start 2025 on time and up to date. Seamlessly integrate your calendars into Dropbox with these simple steps.

Forum Discussion

Edlo11's avatar
Edlo11
Explorer | Level 3
5 years ago

Re: Can't close the page after authentication

Hi, I have the same problem as described: The Dropbox window doesn’t close when I click Allow.   I did use  the "Handle redirect back into SDK" step implemented in my AppDelegate.swift  and I...
  • Greg-DB's avatar
    Greg-DB
    5 years ago

    Right, you need to make sure you're actually calling handleRedirectURL. (In the code you posted, that was missing.)

     

    If you are using scenes, you need to also do this in SceneDelegate.swift. (Apologies that isn't documented yet.) The SDK has changed a bit since the code in that issue was written, but you can do it like this:

        func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
            if let url = URLContexts.first?.url {
                let oauthCompletion: DropboxOAuthCompletion = {
                  if let authResult = $0 {
                      switch authResult {
                      case .success:
                          print("Success! User is logged into DropboxClientsManager.")
                      case .cancel:
                          print("Authorization flow was manually canceled by user!")
                      case .error(_, let description):
                          print("Error: \(String(describing: description))")
                      }
                  }
                }
                DropboxClientsManager.handleRedirectURL(url, completion: oauthCompletion)
            }
        }