DropboxClientsManager

open class DropboxClientsManager

This is a convenience class for the typical single user case. To use this class, see details in the tutorial at: https://www.dropbox.com/developers/documentation/swift#tutorial

For information on the available API methods, see the documentation for DropboxClient

  • An authorized client. This will be set to nil if unlinked.

    Declaration

    Swift

    public static var authorizedClient: DropboxClient?
  • An authorized team client. This will be set to nil if unlinked.

    Declaration

    Swift

    public static var authorizedTeamClient: DropboxTeamClient?
  • Handle a redirect and automatically initialize the client and save the token.

    Declaration

    Swift

    @discardableResult
    public static func handleRedirectURL(_ url: URL, completion: @escaping DropboxOAuthCompletion) -> Bool

    Parameters

    url

    The URL to attempt to handle.

    completion

    The callback closure to receive auth result.

    Return Value

    Whether the redirect URL can be handled.

  • Handle a redirect and automatically initialize the client and save the token.

    Declaration

    Swift

    @discardableResult
    public static func handleRedirectURLTeam(_ url: URL, completion: @escaping DropboxOAuthCompletion) -> Bool

    Parameters

    url

    The URL to attempt to handle.

    completion

    The callback closure to receive auth result.

    Return Value

    Whether the redirect URL can be handled.

  • Unlink the user.

    Declaration

    Swift

    public static func unlinkClients()
  • Unlink the user.

    Declaration

    Swift

    public static func resetClients()
  • Starts a “token” flow.

    Declaration

    Swift

    public static func authorizeFromController(_ sharedApplication: UIApplication, controller: UIViewController?, openURL: @escaping ((URL) -> Void))

    Parameters

    sharedApplication

    The shared UIApplication instance in your app.

    controller

    A UIViewController to present the auth flow from. Reference is weakly held.

    openURL

    Handler to open a URL.

  • Starts the OAuth 2 Authorization Code Flow with PKCE.

    PKCE allows “authorization code” flow without “client_secret” It enables “native application”, which is ensafe to hardcode client_secret in code, to use “authorization code”. PKCE is more secure than “token” flow. If authorization code is compromised during transmission, it can’t be used to exchange for access token without random generated code_verifier, which is stored inside this SDK.

    Note

    If auth completes successfully, A short-lived Access Token and a long-lived Refresh Token will be granted. API calls with expired Access Token will fail with AuthError. An expired Access Token must be refreshed in order to continue to access Dropbox APIs.

    API clients set up by DropboxClientsManager will get token refresh logic for free. If you need to set up DropboxClient/DropboxTeamClient without DropboxClientsManager, you will have to set up the clients with an appropriate AccessTokenProvider.

    Declaration

    Swift

    public static func authorizeFromControllerV2(
        _ sharedApplication: UIApplication, controller: UIViewController?, loadingStatusDelegate: LoadingStatusDelegate?, openURL: @escaping ((URL) -> Void), scopeRequest: ScopeRequest?
    )

    Parameters

    sharedApplication

    The shared UIApplication instance in your app.

    controller

    A UIViewController to present the auth flow from. Reference is weakly held.

    loadingStatusDelegate

    An optional delegate to handle loading experience during auth flow. e.g. Show a loading spinner and block user interaction while loading/waiting. If a delegate is not provided, the SDK will show a default loading spinner when necessary.

    openURL

    Handler to open a URL.

    scopeRequest

    Contains requested scopes to obtain.