MSALNativeAuthPublicClientApplication

@objcMembers
public final class MSALNativeAuthPublicClientApplication : MSALPublicClientApplication

Main interface to interact with the Native Auth methods

To create an instance of the MSALNativeAuthPublicClientApplication use the clientId, tenantSubdomain, challengeTypes and redirectUri (optional) to the initialiser method.

For example:

    do {
        nativeAuth = try MSALNativeAuthPublicClientApplication(
            clientId: "Enter_the_Application_Id_Here",
            tenantSubdomain: "Enter_the_Tenant_Subdomain_Here",
            challengeTypes: [.OOB]
       )
       print("Initialised Native Auth successfully.")
    } catch {
        print("Unable to initialize MSAL \(error)")
    }
  • Initialize a MSALNativePublicClientApplication with a given configuration and challenge types

    Throws

    An error that occurred creating the application object

    Declaration

    Swift

    public init(
        configuration config: MSALPublicClientApplicationConfig,
        challengeTypes: MSALNativeAuthChallengeTypes) throws

    Parameters

    config

    Configuration for PublicClientApplication

    challengeTypes

    The set of capabilities that this application can support as an MSALNativeAuthChallengeTypes optionset

  • Initialize a MSALNativePublicClientApplication.

    Throws

    An error that occurred creating the application object

    Declaration

    Swift

    public init(
        clientId: String,
        tenantSubdomain: String,
        challengeTypes: MSALNativeAuthChallengeTypes,
        redirectUri: String? = nil) throws

    Parameters

    clientId

    The client ID of the application, this should come from the app developer portal.

    tenantSubdomain

    The subdomain of the tenant, this should come from the app developer portal.

    challengeTypes

    The set of capabilities that this application can support as an MSALNativeAuthChallengeTypes optionset

    redirectUri

    Optional. The redirect URI for the application, this should come from the app developer portal.

delegate methods

  • Sign up a user with a given username and password.

    Declaration

    Swift

    public func signUp(
        username: String,
        password: String? = nil,
        attributes: [String: Any]? = nil,
        correlationId: UUID? = nil,
        delegate: SignUpStartDelegate
    )

    Parameters

    username

    Username for the new account.

    password

    Optional. Password to be used for the new account.

    attributes

    Optional. User attributes to be used during account creation.

    correlationId

    Optional. UUID to correlate this request with the server for debugging.

    delegate

    Delegate that receives callbacks for the Sign Up flow.

  • Sign in a user with a given username and password.

    Declaration

    Swift

    public func signIn(
        username: String,
        password: String? = nil,
        scopes: [String]? = nil,
        correlationId: UUID? = nil,
        delegate: SignInStartDelegate
    )

    Parameters

    username

    Username for the account

    password

    Optional. Password for the account.

    scopes

    Optional. Permissions you want included in the access token received after sign in flow has completed.

    correlationId

    Optional. UUID to correlate this request with the server for debugging.

    delegate

    Delegate that receives callbacks for the Sign In flow.

  • Reset the password for a given username.

    Declaration

    Swift

    public func resetPassword(
        username: String,
        correlationId: UUID? = nil,
        delegate: ResetPasswordStartDelegate
    )

    Parameters

    username

    Username for the account.

    correlationId

    Optional. UUID to correlate this request with the server for debugging.

    delegate

    Delegate that receives callbacks for the Reset Password flow.

  • Retrieve the current signed in account from the cache.

    Declaration

    Swift

    public func getNativeAuthUserAccount(correlationId: UUID? = nil) -> MSALNativeAuthUserAccountResult?

    Parameters

    correlationId

    Optional. UUID to correlate this request with the server for debugging.

    Return Value

    An object representing the account information if present in the local cache.