BoxSDK
public class BoxSDK
Provides methods for creating BoxSDKClient
-
SDK-wide constant values
See moreDeclaration
Swift
public enum Constants -
SDK configuration
Declaration
Swift
public private(set) var configuration: BoxSDKConfiguration -
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 -
Initializer
Declaration
Swift
public init(clientId: String, clientSecret: String)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. -
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 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:maxRetryAttempts:tokenRefreshThreshold:logDestination:clientAnalyticsInfo:)Updates current SDK configuration
Declaration
Swift
func updateConfiguration( apiBaseURL: URL? = nil, uploadApiBaseURL: URL? = nil, maxRetryAttempts: Int? = nil, tokenRefreshThreshold: TimeInterval? = nil, logDestination: LogDestination? = nil, clientAnalyticsInfo: ClientAnalyticsInfo? = nil ) throwsParameters
apiBaseURLBase URL for majority of the requests.
uploadApiBaseURLBase URL for upload requests. If not specified, default URL is used.
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.
logDestinationCustom destination of console 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(callbackURL: String? = nil, state: String? = nil) -> URLParameters
callbackURLCustom 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, default URL is used in a format of
boxsdk-clientId://boxsdkoauth2redirectwith the real value ofclientId.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