diff --git a/Source/SwiftyDropbox/Shared/Handwritten/DropboxClientsManager.swift b/Source/SwiftyDropbox/Shared/Handwritten/DropboxClientsManager.swift index ac84da44..a0897cf2 100644 --- a/Source/SwiftyDropbox/Shared/Handwritten/DropboxClientsManager.swift +++ b/Source/SwiftyDropbox/Shared/Handwritten/DropboxClientsManager.swift @@ -326,6 +326,8 @@ public class DropboxClientsManager { public static func handleRedirectURL( _ url: URL, includeBackgroundClient: Bool, + transportClient: DropboxTransportClient? = nil, + backgroundSessionTransportClient: DropboxTransportClient? = nil, sessionConfiguration: NetworkSessionConfiguration? = nil, backgroundSessionConfiguration: NetworkSessionConfiguration? = nil, completion: @escaping DropboxOAuthCompletion @@ -335,12 +337,12 @@ public class DropboxClientsManager { if let result = result { switch result { case .success(let accessToken): - setupAuthorizedClient(accessToken, transportClient: nil, sessionConfiguration: sessionConfiguration) + setupAuthorizedClient(accessToken, transportClient: transportClient, sessionConfiguration: sessionConfiguration) if includeBackgroundClient { setupAuthorizedBackgroundClient( accessToken, - transportClient: nil, + transportClient: backgroundSessionTransportClient, sessionConfiguration: backgroundSessionConfiguration, requestsToReconnect: { _ in } // No need for reconnect as no loads are in progress pre-auth ) @@ -363,6 +365,7 @@ public class DropboxClientsManager { @discardableResult public static func handleRedirectURLTeam( _ url: URL, + transportClient: DropboxTransportClient? = nil, sessionConfiguration: NetworkSessionConfiguration? = nil, completion: @escaping DropboxOAuthCompletion ) -> Bool { @@ -371,7 +374,7 @@ public class DropboxClientsManager { if let result = result { switch result { case .success(let accessToken): - setupAuthorizedTeamClient(accessToken, transportClient: nil, sessionConfiguration: sessionConfiguration) + setupAuthorizedTeamClient(accessToken, transportClient: transportClient, sessionConfiguration: sessionConfiguration) case .cancel, .error: break } diff --git a/Source/SwiftyDropboxObjC/Shared/Handwritten/DBXDropboxClientsManager.swift b/Source/SwiftyDropboxObjC/Shared/Handwritten/DBXDropboxClientsManager.swift index 1808f762..751a1315 100644 --- a/Source/SwiftyDropboxObjC/Shared/Handwritten/DBXDropboxClientsManager.swift +++ b/Source/SwiftyDropboxObjC/Shared/Handwritten/DBXDropboxClientsManager.swift @@ -109,12 +109,46 @@ public class DBXDropboxClientsManager: NSObject { /// - parameters: /// - url: The URL to attempt to handle. /// - includeBackgroundClient: additionally auth background client. + /// - transportClient: A custom transport client to use for network requests. + /// - backgroundSessionTransportClient: A custom transport client to use for background network requests. + /// - sessionConfiguration: A custom session configuration to use for network requests. + /// - backgroundSessionConfiguration: A custom session configuration to use for background network requests. /// - completion: The callback closure to receive auth result. /// - returns: Whether the redirect URL can be handled. @objc @discardableResult - public static func handleRedirectURLTeam(_ url: URL, includeBackgroundClient: Bool, completion: @escaping (DBXDropboxOAuthResult?) -> Void) -> Bool { - DropboxClientsManager.handleRedirectURLTeam(url, completion: bridgeDropboxOAuthCompletion(completion)) + public static func handleRedirectURL( + _ url: URL, + includeBackgroundClient: Bool, + transportClient: DBXDropboxTransportClient?, + backgroundSessionTransportClient: DBXDropboxTransportClient?, + sessionConfiguration: DBXNetworkSessionConfiguration?, + backgroundSessionConfiguration: DBXNetworkSessionConfiguration?, + completion: @escaping (DBXDropboxOAuthResult?) -> Void) -> Bool + { + DropboxClientsManager.handleRedirectURL( + url, + includeBackgroundClient: includeBackgroundClient, + transportClient: transportClient?.swift, + backgroundSessionTransportClient: backgroundSessionTransportClient?.swift, + sessionConfiguration: sessionConfiguration?.swift, + backgroundSessionConfiguration: backgroundSessionConfiguration?.swift, + completion: bridgeDropboxOAuthCompletion(completion) + ) + } + + /// Handle a redirect and automatically initialize the client and save the token. + /// + /// - parameters: + /// - url: The URL to attempt to handle. + /// - transportClient: A custom transport client to use for network requests. + /// - sessionConfiguration: A custom session configuration to use for network requests. + /// - completion: The callback closure to receive auth result. + /// - returns: Whether the redirect URL can be handled. + @objc + @discardableResult + public static func handleRedirectURLTeam(_ url: URL, transportClient: DBXDropboxTransportClient?, sessionConfiguration: DBXNetworkSessionConfiguration?, completion: @escaping (DBXDropboxOAuthResult?) -> Void) -> Bool { + DropboxClientsManager.handleRedirectURLTeam(url, transportClient: transportClient?.swift, sessionConfiguration: sessionConfiguration?.swift, completion: bridgeDropboxOAuthCompletion(completion)) } /// Prepare the appropriate single user DropboxClient to handle incoming background session events and make ongoing tasks available for reconnection