Skip to main content

Enroll Anonymous User

Enroll anonymous user flow allows a device to receive an access token with the lowest access level. For instance, with the help of this token, you can request IAMAccessToken to share with third-party applications for further authorization. This token doesn't contain any user data such as username or email. That's why it calls an anonymous user. You should trigger this flow when you receive from MCSDK sdkState == ActivationRequired. To trigger this flow. Please use EnrollAnonymousUserEvent. As parameters you will need to pass next:

  • tenantId (String)
  • authenticationMode (AuthenticationMode)
  • clientId (String)

Please note that clientId should be properly configured on IDP. By default, we use AstDeviceEnrollment with Device enrollment browser flow.

As a result, you should receive the status OK from MCSDK. By selecting different authenticationModes you can change the type of how your token is stored. It can be (.no, .password, .biometric).

iOS/Swift

Below is the code snippet for Swift to trigger the add user process:

Triggering KSMEnrollAnonymousUserEvent (Swift)
    public func triggerEnrollAnonymousUser(tenant: String, authenticationMode: KSMAuthenticationMode, clientId: String, completion: @escaping (KsEvent) -> Void) {
let tokenRequest = KSMEnrollAnonymousUserEvent(tenantId: tenant, authenticationMode: authenticationMode, clientId: clientId)
masterControllerAdapter.sendEvent2MasterController(tokenRequest) { event in
guard let returnedEvent = event else { return }
completion(returnedEvent)
}
}

Android/Kotlin

In Kotlin you can use below the code snippet for triggering EnrollAnonymousUserEvent:

Triggering EnrollAnonymousUserEvent (Kotlin)
    fun triggerEnrollAnonymousUserEvent(authMode: AuthenticationMode, clientId: String, tenantId: String) {
val enrollAnonymousUserEvent = EnrollAnonymousUserEvent(tenantId, authMode, clientId)

logDebug("triggering EnrollAnonymousUserEvent with tenantId=$tenantId, authMode=$authMode, clientId=$clientId")

mcEventHandler?.postEvent(enrollAnonymousUserEvent)?.then {
logDebug("EnrollAnonymousUser received ResultEvent : $it", "triggerEnrollAnonymousUserEvent", "MCHandler")
}
}