You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
gcarl
4 years agoExplorer | Level 4
iOS - Problems connecting from own app to Dropbox when Dropbox App is installed
Dear community,
since a few days I have the following strange situation.
I have developed an app for iOS which can store data on the Dropbox. The connection is set up as described in the ...
Greg-DB
4 years agoDropbox Staff
Thanks for the report! Can you also share:
- the code you're using to start the authorization flow
- whether or not you also have the non-scenes "Handle redirect back into SDK" code added
- the version number of the Dropbox SDK
- the version number of the Dropbox iOS app
- the version number of iOS
- muthulingam4 years agoExplorer | Level 3
Hi Sir,
i am facing the similar issue .....
1) if "dropbox" app was already installed, then as per the documents, "This launches the official Dropbox iOS app (if installed), authenticates via the official app, then redirects back into the SDK" ... but it does not happens
2) if "dropbox" app was not installed, then there is no problem.(it shows the Authentication screen)
->> i followed exact steps which you guys are described in the tutorials ... (thats why it is working for "non Dropbox app installed" iOS devices.
here is the code snippets related to authentication workflow
in AppDelegate.m (in objective c)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[PhotoPickerEngine.sharedEngine setupSocialNetworks];
}
- (BOOL)application😞UIApplication *)app openURL😞NSURL *)url options😞NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
NSString *urlString = [[[url absoluteString] componentsSeparatedByString:@":"] objectAtIndex:0];
if ([urlString isEqualToString:@"db-xxxxxxxxxx”])
{
[PhotoPickerEngine.sharedEngine handleRedirectURLWithUrl:url]; //dropbox to handle
}
}
//swift code
@objc public func setupSocialNetworks()
{
DropboxClientsManager.setupWithAppKey(“APP_KEY”)
}
@objc public func handleRedirectURL( url: URL)
{
DropboxClientsManager.handleRedirectURL(url, completion: { (authResult) in
switch authResult {
case .success(let token):
print("Success! User is logged into Dropbox with token: \(token)")
EventHub.post(DropboxLoginEvent())
UserDefaults.standard.set(token.accessToken, forKey: Constants.keyAccessTokenDropbox)
case .cancel:
print("User canceld OAuth flow.")
case .error(let error, let description):
print("Error \(error): \(String(describing: description))")
case .none:
break
}
})
}
the version number of the Dropbox SDK : 6.0.3
the version number of the Dropbox iOS app : 258.2.2
the version number of iOS : 15.0.1
can you please help me how to fix this issue?
Thanks ,
muthulingam
- Greg-DB4 years agoDropbox Staff
[Cross-linking for reference: https://github.com/dropbox/SwiftyDropbox/issues/345 ]
muthulingam Thanks for the report. I just tried reproducing this with the same version of the Dropbox SwiftyDropbox SDK and Dropbox app, but it worked successfully for me. My test device is on iOS 15.0.2 though, so it may be worth updating your iOS installation to see if that helps.
Can you elaborate on what you mean when you say "but it does not happens"? What output/error do you get?
By the way, the latest version of the Dropbox SwiftyDropbox 8.2.0. I recommend updating to that, and updating your code to the latest version of the authorization flow as documented.
- gcarl4 years agoExplorer | Level 4
I'm using the following authorization flow, my App is set up in Dropbox with a permanent token:
DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: self, openURL: {(url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil)})
I tried it with your alternative authorization flow as published too, but the result is the same.
The newest SDK version, I can install via cocoaPod is 7.0.1. Astonishingly I can either install version 8.2.0 via CocoaPods ( pod 'SwiftyDropbox', '>=8.0.0' creates an error, only
pod 'SwiftyDropbox', '>=7.0.0' works and leads to 7.0.1) nor via Swift Package Manager with the published link (the link is not found).
iOS-Version is 15.0
- Greg-DB4 years agoDropbox Staff
gcarl While either should technically work, you should use the newer "authorizeFromControllerV2" method as shown here, instead of "authorizeFromController". Is that what you're referring to when you say "alternative authorization flow"?
In any case, I've been unable to reproduce the issue in my own testing, even with the same version of the SDK. You didn't mention which version number of the Dropbox iOS app you have installed though, so please do share that. You can find it in the settings section of the app.
Also, when you run in to this issue, do you get any error or output, such as in the UI or in the Xcode console?
Finally, I also can't reproduce the SDK installation issues you mentioned. If you're still seeing those, can you share the full error/output for those?
- gcarl4 years agoExplorer | Level 4
Dear greg-db,
thanks for your support. Unfortunately, I can't manage it.
I'm using the DropboxApp version 258.2.2.
SwiftyDropbox SDK-version is 7.0.1
For the authorization I use the "authorizeFromControllerV2" as described:
func connectDropbox(withRequest request: Dropboxrequest) {
let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["files.content.write"], includeGrantedScopes: false)
DropboxClientsManager.authorizeFromControllerV2(
UIApplication.shared,
controller: self,
loadingStatusDelegate: nil,
openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) },
scopeRequest: scopeRequest
)
}
and the functions within AppDelegate and in SceneDelegate are as described in the manual:
func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
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))")
}
}
}
for context in URLContexts {
// stop iterating after the first handle-able url
if DropboxClientsManager.handleRedirectURL(context.url, completion: oauthCompletion) { break }
}
}
When trying to read or write a file to Dropbox I'm always referred to the Authorization Screen from the Dropbox and I'm asked if I want to give access permission for my app.
Furthermore I got the following messages:
021-11-05 17:16:15.392198+0000 Kochbuch[36069:5578791] [connection] nw_read_request_report [C4] Receive failed with error "Software caused connection abort"
2021-11-05 17:16:15.411732+0000 Kochbuch[36069:5578791] Task <F851E3DF-4C19-444C-AB1B-82ACB996ACD8>.<4> HTTP load failed, 36/0 bytes (error code: -1005 [1:53])
2021-11-05 17:16:15.412911+0000 Kochbuch[36069:5579146] Task <F851E3DF-4C19-444C-AB1B-82ACB996ACD8>.<4> finished with error [-1005] Error Domain=NSURLErrorDomain Code=-1005 "Die Netzwerkverbindung wurde unterbrochen." UserInfo={_kCFStreamErrorCodeKey=53, NSUnderlyingError=0x2806e0840 {Error Domain=kCFErrorDomainCFNetwork Code=-1005 "(null)" UserInfo={_kCFStreamErrorCodeKey=53, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <F851E3DF-4C19-444C-AB1B-82ACB996ACD8>.<4>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <F851E3DF-4C19-444C-AB1B-82ACB996ACD8>.<4>"
), NSLocalizedDescription=Die Netzwerkverbindung wurde unterbrochen., NSErrorFailingURLStringKey=https://api.dropbox.com/oauth2/token, NSErrorFailingURLKey=https://api.dropbox.com/oauth2/token, _kCFStreamErrorDomainKey=1}
Error: nil
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days agoIf 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 or Facebook.
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!