DBOAuthManager
Objective-C
@interface DBOAuthManager : NSObject <DBAccessTokenRefreshing> {
  NSString *_appKey;
  NSURL *_redirectURL;
  NSURL *_cancelURL;
  NSString *_host;
  NSMutableArray<NSURL *> *_urls;
  DBOAuthPKCESession *_authSession;
}
                Swift
class DBOAuthManager : NSObject, DBAccessTokenRefreshing
                Platform-neutral manager for performing OAuth linking.
Note
OAuth flow webviews localize to environment locale.- 
                  
                  
Sets the locale of the OAuth flow webpages. If
nil, then defaults to device locale.Declaration
Objective-C
@property (nonatomic, strong) NSLocale *_Nonnull locale;Swift
var locale: Locale { get set } 
- 
                  
                  
Accessor method for
DBOAuthManagershared instance.Shared instance is used to authenticate users through OAuth2, save access tokens, and retrieve access tokens.
Declaration
Objective-C
+ (nullable DBOAuthManager *)sharedOAuthManager;Swift
class func shared() -> DBOAuthManager?Return Value
The
DBOAuthManagershared instance. - 
                  
                  
Mutator method for
DBOAuthManagershared instance.Shared instance is used to authenticate users through OAuth2, save access tokens, and retrieve access tokens.
Declaration
Objective-C
+ (void)setSharedOAuthManager:(nonnull DBOAuthManager *)sharedOAuthManager;Swift
class func setShared(_ sharedOAuthManager: DBOAuthManager)Parameters
sharedOAuthManagerThe updated reference to the
DBOAuthManagershared instance. 
- 
                  
                  
DBOAuthManagerconvenience constructor.Declaration
Objective-C
- (nonnull instancetype)initWithAppKey:(nonnull NSString *)appKey;Swift
init(appKey: String)Parameters
appKeyThe app key from the developer console that identifies this app.
Return Value
An initialized instance.
 - 
                  
                  
DBOAuthManagerconvenience constructor.Declaration
Objective-C
- (nonnull instancetype)initWithAppKey:(nonnull NSString *)appKey host:(nullable NSString *)host;Swift
init(appKey: String, host: String?)Parameters
appKeyThe app key from the developer console that identifies this app.
hostThe host of the OAuth web flow. Leave nil to use default host.
Return Value
An initialized instance.
 - 
                  
                  
DBOAuthManagerfull constructor.Declaration
Objective-C
- (nonnull instancetype)initWithAppKey:(nonnull NSString *)appKey host:(nullable NSString *)host redirectURL:(nullable NSString *)redirectURL;Swift
init(appKey: String, host: String?, redirectURL: String?)Parameters
appKeyThe app key from the developer console that identifies this app.
hostThe host of the OAuth web flow. Leave nil to use default host.
redirectURLThe redirect url of the OAuth web flow. Default to “db-
://2/token” Return Value
An initialized instance.
 
- 
                  
                  
Commences the authorization flow (platform-neutral).
Interfaces with platform-specific rendering logic via the
DBSharedApplicationprotocol.Declaration
Objective-C
- (void)authorizeFromSharedApplication: (nonnull id<DBSharedApplication>)sharedApplication;Parameters
sharedApplicationA platform-neutral shared application abstraction for rendering auth flow.
 - 
                  
                  
Commences the authorization flow (platform-neutral).
Interfaces with platform-specific rendering logic via the
DBSharedApplicationprotocol.Declaration
Objective-C
- (void)authorizeFromSharedApplication: (nonnull id<DBSharedApplication>)sharedApplication usePkce:(BOOL)usePkce scopeRequest:(nullable DBScopeRequest *)scopeRequest;Parameters
sharedApplicationA platform-neutral shared application abstraction for rendering auth flow.
usePkceWhether to use OAuth2 code flow with PKCE.
scopeRequestThe ScopeRequest, only used in code flow with PKCE.
 - 
                  
                  
Handles a redirect back into the application (from whichever auth flow was being used).
Declaration
Objective-C
- (BOOL)handleRedirectURL:(nonnull NSURL *)url completion:(nonnull DBOAuthCompletion)completion;Swift
func handleRedirectURL(_ url: URL, completion: @escaping DBOAuthCompletion) -> BoolParameters
urlThe redirect URL to attempt to handle.
completionCompletion block for oauth result, called with
nilif SDK cannot handle the redirect URL, otherwise an instance ofDBOAuthResult.Return Value
Whether the URL can be handled.
 
- 
                  
                  
Saves an access token to the
DBKeychainclass.Declaration
Objective-C
- (BOOL)storeAccessToken:(nonnull DBAccessToken *)accessToken;Swift
func store(_ accessToken: DBAccessToken) -> BoolParameters
accessTokenThe access token to save.
Return Value
Whether the save operation succeeded.
 - 
                  
                  
Utility function to return an arbitrary access token from the
DBKeychainclass, if any exist.Declaration
Objective-C
- (nullable DBAccessToken *)retrieveFirstAccessToken;Swift
func retrieveFirstAccessToken() -> DBAccessToken?Return Value
the “first” access token found, if any, otherwise nil.
 - 
                  
                  
Retrieves the access token for a particular user from the
DBKeychainclass.Declaration
Objective-C
- (nullable DBAccessToken *)retrieveAccessToken:(nonnull NSString *)tokenUid;Swift
func retrieveAccessToken(_ tokenUid: String) -> DBAccessToken?Parameters
tokenUidThe uid of the access token to retrieve.
Return Value
An access token if present, otherwise nil.
 - 
                  
                  
Retrieves all stored access tokens from the
DBKeychainclass.Declaration
Objective-C
- (nonnull NSDictionary<NSString *, DBAccessToken *> *)retrieveAllAccessTokens;Swift
func retrieveAllAccessTokens() -> [String : DBAccessToken]Return Value
a dictionary mapping token uids to their access tokens.
 - 
                  
                  
Checks if there are any stored access tokens in the
DBKeychainclass.Declaration
Objective-C
- (BOOL)hasStoredAccessTokens;Swift
func hasStoredAccessTokens() -> BoolReturn Value
Whether there are stored access tokens.
 - 
                  
                  
Deletes a specific access tokens from the
DBKeychainclass.Declaration
Objective-C
- (BOOL)clearStoredAccessToken:(nonnull NSString *)tokenUid;Swift
func clearStoredAccessToken(_ tokenUid: String) -> BoolParameters
tokenUidThe uid of the access token to delete.
Return Value
Whether the delete operation succeeded.
 - 
                  
                  
Deletes all stored access tokens in the
DBKeychainclass.Declaration
Objective-C
- (BOOL)clearStoredAccessTokens;Swift
func clearStoredAccessTokens() -> BoolReturn Value
Whether the batch deletion operation succeeded.
 - 
                  
                  
When YES users will not be able to sign up for a Dropbox account via the authorization page. Instead, the authorization page will show a link to the Dropbox iOS app in the App Store. This is was originally intended for use when necessary for compliance with App Store policies.
Default value is YES.
NOTE: Recent App Store policy suggests that sign up is now allowed, so it should be safe to enable signup. However we are keeping the parameter and defaulting to YES to allow SDK users to make the appropriate decision for their apps.
Declaration
Objective-C
@property (nonatomic) BOOL disableSignup;Swift
var disableSignup: Bool { get set } - 
                  
                  
When YES, users who use the web auth flow (NOT dbapp delegated auth) will be forced to sign in from scratch. When NO, there is saved session data from the SafariViewController that can be used across signin attempts. This is intended for use with multi-account applications for App Store compliance, since adding a second account would shortcut the username/password entry page and use the first account’s credentials.
Default value is NO, which is consistent with historical behavior.
Declaration
Objective-C
@property (nonatomic) BOOL webAuthShouldForceReauthentication;Swift
var webAuthShouldForceReauthentication: Bool { get set } 
View on GitHub
        DBOAuthManager Class Reference