login(withRequest)
AppDelegate.reachfive().login( withRequest, usingModalAuthorizationFor, display )
Description
Logs the user in using credentials stored in the keychain. The system displays all available credentials in a modal sheet. Credentials can be any combination of passwords, passkeys, or Sign in with Apple.
In the case where step-up authentication is required, loginWithRequest
returns an OngoingStepUp
response.
Usage
Start this request in response to a user interaction.
Setting the parameter display
to .Always
works best.
Alternatively, start the request automatically early in a view lifecycle (e.g., in viewDidAppear
) or during the application launch.
Prefer setting display
to .IfImmediatelyAvailableCredentials
for this use case.
Examples
AppDelegate
.reachfive()
.login(withRequest: NativeLoginRequest(anchor: window), usingModalAuthorizationFor: [.Passkey, .Password, .SignInWithApple], display: .IfImmediatelyAvailableCredentials)
// get auth token on success
.onSuccess { authToken in
}
.onFailure { error in
switch error {
case .AuthCanceled: return // No credentials are available. If called at app launch, do nothing. If called in `viewDidAppear`, presents other options for the user to login.
default: return // Real failure.
}
}
Parameters
Parameter | Description |
---|---|
Object containing parameters to send along with the request. Object parameters:
|
|
An array of types of credential to unlock. Any combination of |
|
Choice of behaviour when there are no credentials available. options
|
Response
Type: Future<LoginFlow.AchievedLogin | OngoingStepUp, ReachFiveError>
If the credentials are valid, the promise returns the profile’s authentication token or continues the step-up process depending on the flow.
Otherwise it is rejected and returns a ReachFiveError
.
AchievedLogin
Returns the authentication token.
idToken |
The ID token JSON Web Token (JWT) that contains the profile’s information. This is only available when the |
||||||||||||||||||||||||||||||||||
accessToken |
The authorization credential JSON Web Token (JWT) used to access the ReachFive API. |
||||||||||||||||||||||||||||||||||
refreshToken |
The refresh token JSON Web Token (JWT) used to obtain new access tokens once they expire. This is only available when the |
||||||||||||||||||||||||||||||||||
tokenType |
The type of token. Always equal to |
||||||||||||||||||||||||||||||||||
expiresIn |
The lifetime in seconds of the access token. If |
||||||||||||||||||||||||||||||||||
user OpenIDUser |
The user’s information contained in the ID token.
|
OngoingStepUp
Field | Description |
---|---|
token |
The token obtained after initiating the step-up flow. |
availableMfaCredentialItemTypes |
The MFA credential type such as |
ReachFiveError
Based on the problem, the ReachFiveError
will be:
-
AuthCanceled
: The user cancelled the request or no credential was available in the keychain. -
RequestError(apiError: ApiError)
for a Bad Request (status 400) error. -
AuthFailure(reason: String, apiError: ApiError?)
mainly for Unauthorized (status 401) error. -
TechnicalError(reason: String, apiError: ApiError?)
if it’s an Internal Server Error (status 500) or other internal errors.
ApiError
error |
The main error message. |
||||||
errorId |
The identifier of the error. |
||||||
errorUserMsg |
The user-friendly error message.
|
||||||
errorMessageKey |
The error message key. |
||||||
errorDescription |
The technical error message. |
||||||
errorDetails FieldError[] |
|