SmartcarAuth
@objcMembers
public class SmartcarAuth : NSObject
Smartcar Authentication SDK for iOS written in Swift 5. - Facilitates the authorization flow to launch the flow and retrieve an authorization code
-
Constructor for the SmartcarAuth
Declaration
Swift
public init( clientId: String, redirectUri: String, scope: [String], completionHandler: @escaping (String?, String?, String?, AuthorizationError?) -> Void, testMode: Bool = false, mode: SCMode? = nil )Parameters
clientIdThe application’s client ID
redirectUriThe application’s redirect URI. Must be a valid URI.
scopeAn array of authorization scopes
completionCallback function called upon the completion of the Smartcar Connect
testModeDeprecated, please use
modeinstead. Optional, launch the Smartcar auth flow in test mode when set to true. Defaults to false.modeOptional, determine what mode Smartcar Connect should be launched in. Should be one of .test, .live or .simulated. If none specified, defaults to live mode.
-
Helper method to generate a SCURLBuilder instance, which then can be used (with various setters) to build an auth URL See
SCURLBuilderfor a full list of query parameters that can be set on the authorization URLDeclaration
Swift
public func authUrlBuilder() -> SCUrlBuilder -
Starts the launch of Smartcar Connect.
Declaration
Swift
public func launchAuthFlow(url: String, viewController: UIViewController)Parameters
authUrlthe authorization URL for Smartcar Connect. Use
SCURLBuilderto generate a auth URLviewControllerThe view controller responsible for presenting the Connect flow
-
Authorization callback function. Verifies that no error occured during the OAuth process and extracts the auth code, state string, and virtualKeyUrl upon success. Invokes the completion function with either the code or an error (and state and/or virtualKeyUrl if included).
Declaration
Swift
public func handleCallback(callbackUrl: URL)Parameters
urlcallback URL containing authorization code or an error
SmartcarAuth Class Reference