Login
When you receive a StartResultEvent with LOGIN_REQUIRED as the sdkState in response to a StartEvent, you should initiate the Login flow.
This process involves triggering the KSSIDP login to provide the username and password to the IDP. It's crucial to follow the specified flows in the correct sequence to ensure a seamless and successful login process.
KSSIDP Login Flow Diagram for KOBIL Shift Lite
The following event flow diagram illustrates the sequence of events during the login process for KOBIL Shift Lite - KSSIDP:
To integrate the login flow, follow the steps below. The file names shown are for reference and ease of understanding—you can modify your integration approach, but you must follow the same sequence to achieve the correct result.
Implementation Examples
Swift/iOS
The KssIdpLogin
function acts as a bridge between the user interface and the identity provider. This function uses the login method from kssIdpWrapper to trigger the login process, with results handled by the handleResult
function.
func KssIdpLogin(
clientId: String,
authMode: KSMAuthenticationMode,
credentials: [String: String]) {
self.kssIdpWrapper.login(
clientId: clientId,
credentials: credentials,
authMode: authMode
) { resultObject, _ in
handleResult(resultObject: resultObject)
}
}
Android/Kotlin
This function uses the login method from the KssIdp Instance to trigger the login process, with results handled by the onResultReceived listener.
fun triggerKssIdpLogin(
clientId: String,
authMode: AuthenticationMode,
credentials: HashMap<String, String>,
onResultReceived: ((result: ResultObject) -> Unit)? = onResultReceivedCallback
) {
launchIO {
KssIdp.getInstance()?.login(clientId, authMode, credentials, onResultReceived)?.then {
// handle result
}
}
}
Flutter/Dart
The Flutter implementation uses the KssIdpApi to trigger the login process. This function handles user credentials and processes the login result through the IDP flow.
Future<void> performKssLogin(String username, String password) async {
try {
// Create credentials map
final credentials = {
'username': username,
'password': password,
};
// Get your KssIdpApi instance
final kssIdpHelper = locator<KssIdpHelper>();
// Perform the login
final loginResult = await kssIdpHelper.idpApi.login(
'your-client-id',
AuthenticationMode.no, // Or your preferred auth mode
credentials,
);
// Handle the login result
switch (loginResult.status.runtimeType) {
case KssIdpStatusSuccess:
print("✅ Login successful");
break;
case KssIdpStatusRequestFailed:
final error = (loginResult.status as KssIdpStatusRequestFailed).errorDescription;
print("❌ Login request failed: $error");
break;
case KssIdpStatusEventFailed:
final error = (loginResult.status as KssIdpStatusEventFailed).errorDescription;
print("❌ Login event failed: $error");
break;
default:
print("❓ Unknown login result status");
}
} catch (e) {
print("❌ Login exception: $e");
// Handle exception
}
}
For an example that is using Flutter Redux for state management, you can view our provided demo app.
Request Parameters
The following parameters are used in KSSIDP Login:
clientId: This value is provided by the KOBIL IDP services.
credentials: {
"username": VALUE-TO-PASS,
"password": VALUE-TO-PASS
}
Important Notes
INFO: In the KOBIL Shift Lite environment, you can choose between several authentication modes during the KSSIDP Login implementation.
For more information about MC usage during KSSIDP flows, please refer to the CreateHttpCommonRequest and SetAuthorisationCode events.
Response Handling
In response to a LoginEvent, KSSIDP sends a SetAuthorisationCodeResultEvent with the appropriate status.
Stay Logged In
An activated user can remain logged in for a predefined duration if they have a valid session on the IDP and valid tokens stored in MC. To learn more, read Stay Logged In.