I have a problem connecting the Dropbox API to my application. Dropbox API documentation is in front of my eyes, I do everything as it is written there. But in some of the methods that are indicated there are errors and I do not know what to replace the entities that are indicated there. I can log in, but I cannot get the token, error instead: "-canOpenURL: failed for URL: "dbapi-2://1/connect" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
import SwiftyDropbox
class AppDelegate:... {
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
//error Use of undeclared type 'DropboxOAuthCompletion'
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)
return true
}
}
import SwiftyDropbox
class ViewController:... {
func openDropboxAutorization() {
// Legacy authorization flow that grants a long-lived token.
DropboxClientsManager.authorizeFromController(UIApplication.shared,
controller: self,
openURL: { (url: URL) -> Void in
UIApplication.shared.open(url, options: [:], completionHandler: nil)
})
//New: OAuth 2 code flow with PKCE that grants a short-lived token with scopes.
//error Use of unresolved identifier 'ScopeRequest'
let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["account_info.read"], includeGrantedScopes: false)
DropboxClientsManager.authorizeFromControllerV2(
UIApplication.shared,
controller: self,
loadingStatusDelegate: nil,
openURL: { (url: URL) -> Void in UIApplication.shared.openURL(url) },
scopeRequest: scopeRequest
)
}
}
Both of these methods are copied from the DropboxAppi documentation, but they don't work and I can't find the right solution.