DropboxOAuthManager

open class DropboxOAuthManager

Manages access token storage and authentication

Use the DropboxOAuthManager to authenticate users through OAuth2, save access tokens, and retrieve access tokens.

@note OAuth flow webviews localize to enviroment locale.

  • A shared instance of a DropboxOAuthManager for convenience

    Declaration

    Swift

    public static var sharedOAuthManager: DropboxOAuthManager!
  • Create an instance parameter appKey: The app key from the developer console that identifies this app.

    Declaration

    Swift

    convenience public init(appKey: String)
  • Try to handle a redirect back into the application

    Declaration

    Swift

    open func handleRedirectURL(_ url: URL) -> DropboxOAuthResult?

    Parameters

    url

    The URL to attempt to handle

  • Present the OAuth2 authorization request page by presenting a web view controller modally

    Declaration

    Swift

    open func authorizeFromSharedApplication(_ sharedApplication: SharedApplication)

    Parameters

    controller

    The controller to present from

  • Retrieve all stored access tokens

    Declaration

    Swift

    open func getAllAccessTokens() -> [String : DropboxAccessToken]

    Return Value

    a dictionary mapping users to their access tokens

  • Check if there are any stored access tokens

    Declaration

    Swift

    open func hasStoredAccessTokens() -> Bool

    Return Value

    Whether there are stored access tokens

  • Retrieve the access token for a particular user

    Declaration

    Swift

    open func getAccessToken(_ user: String?) -> DropboxAccessToken?

    Parameters

    user

    The user whose token to retrieve

    Return Value

    An access token if present, otherwise nil.

  • Delete a specific access token

    Declaration

    Swift

    open func clearStoredAccessToken(_ token: DropboxAccessToken) -> Bool

    Parameters

    token

    The access token to delete

    Return Value

    whether the operation succeeded

  • Delete all stored access tokens

    Declaration

    Swift

    open func clearStoredAccessTokens() -> Bool

    Return Value

    whether the operation succeeded

  • Save an access token

    Declaration

    Swift

    open func storeAccessToken(_ token: DropboxAccessToken) -> Bool

    Parameters

    token

    The access token to save

    Return Value

    whether the operation succeeded

  • Utility function to return an arbitrary access token

    Declaration

    Swift

    open func getFirstAccessToken() -> DropboxAccessToken?

    Return Value

    the first access token found, if any (otherwise nil)