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: I can't get a logged in instance of DropboxClient

I can't get a logged in instance of DropboxClient

ShinehahGnolaum
Helpful | Level 7
Go to solution

In another post about the 10814 error it said I could ignore the error, but in this case it looks like I'm not getting the instance of DropboxClient even after I log in.

 

I get the following messages in my debug window:

Spoiler

DropboxViewController.viewWillAppear(_:)

2018-08-06 20:23:28.434567-0500 Gnolaum[35840:1973880] -canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

2018-08-06 20:23:28.437971-0500 Gnolaum[35840:1973880] -canOpenURL: failed for URL: "dbapi-8-emm://1/connect" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"

When I run the following code:

    override func viewWillAppear(_ animated: Bool) {
        
        print("DropboxViewController.viewWillAppear(_:)")
        
        if let client = DropboxClientsManager.authorizedClient {
            
            // List contents of app folder
            _ = client.files.listFolder(path: "").response { response, error in
                if let result = response {
                    print("Folder contents:")
                    for entry in result.entries {
                        print(entry.name)
                        self.filenames?.append(entry.name)
                    }
                }
            }
            
        } else {
            // Present view to log in
            DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: self, openURL: {(url: URL) -> Void in UIApplication.shared.openURL(url)})
        }
        
    }

This is code I copied from the PhotoWatch sample. It works there. I also don't get the error 10814 in PhotoWatch. Why will my code not work?

 

In another part of my code, I do notice that I am able to get an instance of DrobpoxClient using 

DropboxClient(accessToken:)

 

2 Accepted Solutions

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

The installation method isn't what I was referring to, but o clarify, there are three distinct methods for installing the library:

  1. CocoaPods
  2. Carthage
  3. Manually add subproject

You can and should only use one of them. Each one is sufficient for installing the library. Within each method, all of the steps are required, unless stated otherwise.

 

In any case, the exact installation method that you use isn't relevant to your original authorizedClient question here. As long as the installation was successful, each of them result in a library that you use the same way.

 

After installation, however, there are more, not optional, steps you need to follow to make sure you can process the app authorization flow properly. Can you confirm you followed all of the instructions under "Configure your project" in particular?

 

If so, you should be able to go through the app authorization flow in your app like an end-user would, and then when you get back you can get a client from authorizedClient.

 

If that's not working properly, please share the rest of the relevant code (e.g., the code in your app delegate, per the intstructions, etc.).

View solution in original post

ShinehahGnolaum
Helpful | Level 7
Go to solution

In the process of checking my steps, I tried adding the succeeding step

https://github.com/dropbox/SwiftyDropbox#handle-redirect-back-into-sdk

and it worked.

 

Thank you for your help.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution
Can you confirm that you followed all of the instructions under "Configure your project" and "Handling the authorization flow"?

https://github.com/dropbox/SwiftyDropbox#configure-your-project

Those instructions cover the necessary steps for implementing the app authorization flow, so that you can retrieve a client using authorizedClient.

ShinehahGnolaum
Helpful | Level 7
Go to solution

I followed the instructions exactly. When I ran into problems, I was able to get help by posting in GitHub and on this forum and was able to correct the errors. I chose to use Carthage and chose not to do the manual step at this link:

https://github.com/dropbox/SwiftyDropbox#manually-add-subproject

Am I correct to assume that step was only to be taken if I had not taken the previous step? I take it I would not need to add the SwiftyDropbox and Alamofire Xcode projects manually into my Xcode projects if I already added the frameworks into my projects.

Greg-DB
Dropbox Staff
Go to solution

The installation method isn't what I was referring to, but o clarify, there are three distinct methods for installing the library:

  1. CocoaPods
  2. Carthage
  3. Manually add subproject

You can and should only use one of them. Each one is sufficient for installing the library. Within each method, all of the steps are required, unless stated otherwise.

 

In any case, the exact installation method that you use isn't relevant to your original authorizedClient question here. As long as the installation was successful, each of them result in a library that you use the same way.

 

After installation, however, there are more, not optional, steps you need to follow to make sure you can process the app authorization flow properly. Can you confirm you followed all of the instructions under "Configure your project" in particular?

 

If so, you should be able to go through the app authorization flow in your app like an end-user would, and then when you get back you can get a client from authorizedClient.

 

If that's not working properly, please share the rest of the relevant code (e.g., the code in your app delegate, per the intstructions, etc.).

ShinehahGnolaum
Helpful | Level 7
Go to solution

In the process of checking my steps, I tried adding the succeeding step

https://github.com/dropbox/SwiftyDropbox#handle-redirect-back-into-sdk

and it worked.

 

Thank you for your help.

Need more support?