BoxSDK
public class BoxSDK
Provides methods for creating BoxSDKClient
-
Box-specific constants
See moreDeclaration
Swift
public enum Constants -
SDK configuration
Declaration
Swift
public private(set) var configuration: BoxSDKConfiguration { get } -
Default configuration
Declaration
Swift
public static let defaultConfiguration: BoxSDKConfiguration -
Auth module providing authorization and token related requests. Is set upon BoxSDK initialisation
Declaration
Swift
public private(set) var auth: AuthModule { get } -
Initializer
Declaration
Swift
public init(clientId: String, clientSecret: String, callbackURL: String? = nil)Parameters
clientIdThe client ID of the application requesting authentication. To get the client ID for your application, log in to your Box developer console click the Edit Application link for the application you’re working with. In the OAuth 2 Parameters section of the configuration page, find the item labeled “client_id”. The text of that item is your application’s client ID.
clientSecretThe client secret of the application requesting authentication. To get the client secret for your application, log in to your Box developer console and click the Edit Application link for the application you’re working with. In the OAuth 2 Parameters section of the configuration page, find the item labeled “client_secret”. The text of that item is your application’s client secret.
callbackURLAn optional custom callback URL string. The URL to which Box redirects the browser when authentication completes. The user’s actual interaction with your application begins when Box redirects to this URL. If not specified, the default URL is used, in the format of
boxsdk-CLIENTID://boxsdkoauth2redirect, where CLIENTID is replaced with the value of theclientIdparameter.
-
Creates BoxClient object based on developer token
Declaration
Swift
public static func getClient(token: String) -> BoxClientParameters
tokenDeveloper token
Return Value
New BoxClient object
-
Creates BoxClient with developer token
Declaration
Swift
public func getClient(token: String) -> BoxClientParameters
tokenDeveloper token
Return Value
New BoxClient object
-
Creates BoxClient using JWT token.
Declaration
Swift
public func getDelegatedAuthClient( authClosure: @escaping DelegatedAuthClosure, uniqueID: String, tokenInfo: TokenInfo? = nil, tokenStore: TokenStore? = nil, completion: @escaping Callback<BoxClient> )Parameters
tokenInfoInformation about token
tokenStoreCustom token store. To use custom store, implement TokenStore protocol.
authClosureRequests new JWT token value when needed. Provide the token value from your token provider.
uniqueIDUnique identifier provided for jwt token.
completionReturns standard BoxClient object or error.
-
Creates BoxClient using Server Authentication with Client Credentials Grant for account service
Declaration
Swift
public func getCCGClientForAccountService( enterpriseId: String, tokenInfo: TokenInfo? = nil, tokenStore: TokenStore? = nil, completion: @escaping Callback<BoxClient> )Parameters
enterpriseIdThe enterprise ID to use when getting the access token.
tokenInfoInformation about token
tokenStoreCustom token store. To use custom store, implement TokenStore protocol.
completionReturns standard BoxClient object or error.
-
Creates BoxClient using Server Authentication with Client Credentials Grant for user account
Declaration
Swift
public func getCCGClientForUser( userId: String, tokenInfo: TokenInfo? = nil, tokenStore: TokenStore? = nil, completion: @escaping Callback<BoxClient> )Parameters
userIdThe user ID to use when getting the access token.
tokenInfoInformation about token
tokenStoreCustom token store. To use custom store, implement TokenStore protocol.
completionReturns standard BoxClient object or error.
-
Creates BoxClient in a completion with OAuth 2.0 type of authentication
Declaration
Swift
@available(iOS 13.0, *) public func getOAuth2Client( tokenInfo: TokenInfo? = nil, tokenStore: TokenStore? = nil, context: ASWebAuthenticationPresentationContextProviding, completion: @escaping Callback<BoxClient> )Parameters
tokenInfoInformation about token
tokenStoreCustom token store. To use custom store, implement TokenStore protocol.
contextThe ViewController that is presenting the OAuth request
completionReturns created standard BoxClient object or error
-
Creates BoxClient in a completion with OAuth 2.0 type of authentication
Declaration
Swift
@available(iOS 11.0, *) public func getOAuth2Client( tokenInfo: TokenInfo? = nil, tokenStore: TokenStore? = nil, completion: @escaping Callback<BoxClient> )Parameters
tokenInfoInformation about token
tokenStoreCustom token store. To use custom store, implement TokenStore protocol.
completionReturns created standard BoxClient object or error
-
updateConfiguration(apiBaseURL:uploadApiBaseURL: oauth2AuthorizeURL: maxRetryAttempts: tokenRefreshThreshold: consoleLogDestination: fileLogDestination: clientAnalyticsInfo: ) Updates current SDK configuration
Declaration
Swift
func updateConfiguration( apiBaseURL: URL? = nil, uploadApiBaseURL: URL? = nil, oauth2AuthorizeURL: URL? = nil, maxRetryAttempts: Int? = nil, tokenRefreshThreshold: TimeInterval? = nil, consoleLogDestination: ConsoleLogDestination? = nil, fileLogDestination: FileLogDestination? = nil, clientAnalyticsInfo: ClientAnalyticsInfo? = nil ) throwsParameters
apiBaseURLBase URL for majority of the requests.
uploadApiBaseURLBase URL for upload requests. If not specified, default URL is used.
oauth2AuthorizeURLURL for the OAuth2 authorization page, where users are redirected to enter their credentials
maxRetryAttemptsMaximum number of request retries in case of error result. If not specified, default value 5 is used.
tokenRefreshThresholdSpecifies how many seconds before token expires it shuld be refreshed. If not specified, default value 60 seconds is used.
consoleLogDestinationCustom destination of console log.
fileLogDestinationCustom destination of file log.
clientAnalyticsInfoCustom analytics info that will be set to request header.
-
Creates OAuth2 authorization URL you can use in browser to authorize.
Declaration
Swift
public func makeAuthorizeURL(state: String? = nil) -> URLParameters
stateA text string that you choose. Box sends the same string to your redirect URL when authentication is complete. This parameter is provided for your use in protecting against hijacked sessions and other attacks.
Return Value
Standard URL object to be used for authorization in external browser.
BoxSDK Class Reference