DXAuthClient

This class is responsible for configuring the SDK with your app's credentials, as well as authenticating your users.

public final class DXAuthClient

The DXAuthClient class is the entry point in the SDK for your app. It's where you will configure the SDK to use your app's credentials (client id and secret), environment, and redirect URI. It's also used to authenticate users through the Single-Sign On flow, as well as log users out.

A user may skip the SSO flow and sign in as a "Guest User" if they do not have a DX account. To include this feature in your app, you must have a screen for the user to enter their date of birth that does not have a back button option. For more information, see createAnonymousUser.

Properties

public static let shared: DXAuthClient

Singleton instance of DXAuthClient. You will access all the available DXAuthClient methods through this instance.

Methods

configure

public func configure(
    forEnvironment environment: DXEnvironment, 
    withClientId clientId: String, 
    andClientSecret clientSecret: String, 
    andRedirectURI redirectURI: String
) -> Void

This method will configure the SDK for your app using your app's credentials (client id and secret), redirect URI, and the environment your app is using.

This method must be called before using any other methods in the SDK.

Parameter

Type

Description

forEnvironment

DXEnvironment

The DXEnvironment your app is currently executing in.

withClientId

String

The client id for your app created in the developer dashboard.

andClientSecret

String

The client secret for your app created in the developer dashboard.

andRedirectURI

String

The redirect URI registered for your app in the developer dashboard.

isAuthenticated

public func isAuthenticated(
    loginDelegate: DXLoginDelegate? = nil, 
    _ completion: @escaping (_ error: Error?, _ userProfile: DXProfile?) -> Void
    ) -> Void

Checks if there is a DX user currently authenticated through the SDK. If not, your app will need to initiate the SSO flow.

Parameter

Type

Description

loginDelegate

DXLoginDelegate?

An optional instance of DXLoginDelegate that can respond to various authentication events (failed login, logout, etc).

completion

(Error?, DXProfile?) -> Void

The closure that will be invoked after checking if there is an authenticated user. If there is an authenticated user, it will be invoked with an instance of DXProfile. If an error occurs, it will be invoked with an instance of Error.

open

public func open(url: URL) -> Void

Extracts authentication tokens on a successful redirect. Your AppDelegate will need to implement application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool and invoke this method, passing in the url argument.

Parameter

Type

Description

url

URL

The URL instance passed after a successful redirect.

logout

public func logout() -> Void

Logout the currently authenticated user.

Last updated