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

    clientId

    The application’s client ID

    redirectUri

    The application’s redirect URI. Must be a valid URI.

    scope

    An array of authorization scopes

    completion

    Callback function called upon the completion of the Smartcar Connect

    testMode

    Deprecated, please use mode instead. Optional, launch the Smartcar auth flow in test mode when set to true. Defaults to false.

    mode

    Optional, 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 SCURLBuilder for a full list of query parameters that can be set on the authorization URL

    Declaration

    Swift

    public func authUrlBuilder() -> SCUrlBuilder
  • Starts the launch of Smartcar Connect.

    Declaration

    Swift

    public func launchAuthFlow(url: String, viewController: UIViewController)

    Parameters

    authUrl

    the authorization URL for Smartcar Connect. Use SCURLBuilder to generate a auth URL

    viewController

    The 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

    url

    callback URL containing authorization code or an error