PlayPortalAuthClient

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

The PlayPortalAuthClient 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 playPORTAL 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: PlayPortalAuthClient

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

Methods

configure

public func configure(forEnvironment environment: PlayPortalEnvironment, 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

PlayPortalEnvironment

The PlayPortalEnvironment 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: PlayPortalLoginDelegate? = nil, _ completion: @escaping (_ error: Error?, _ userProfile: PlayPortalProfile?) -> Void -> Void

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

Parameter

Type

Description

loginDelegate

PlayPortalLoginDelegate?

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

completion

(Error?, PlayPortalProfile?) -> 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 PlayPortalProfile. 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.