signInOrCreateMember

abstract suspend fun signInOrCreateMember(externalUserId: String, email: String? = null, firstName: String? = null, middleName: String? = null, lastName: String? = null, gender: String? = null, dateOfBirth: String? = null, phoneNumber: String? = null, address1: String? = null, address2: String? = null, city: String? = null, state: String? = null, zip: String? = null, attributes: Map<String, String?>? = null): AFResult

Attempts to authenticate a member using their externalUserId.

This flow is intended for organization accounts that do not use eligibility files. Instead, members are identified and authenticated directly by a tenant-unique identifier.

Legacy / backend-only. This method calls /api/v1/auth/token directly and therefore requires the Client Secret to be present in AFCoreConfig. That is acceptable for backend-only services, local development, and legacy tenants, but not for production mobile apps (a bundled secret is extractable). For the secure mobile pattern, have your backend perform the token exchange and adopt the result with authenticateWithTokens instead.

Return

true if authentication succeeded; false if the member could not be found.

Parameters

externalUserId

A tenant-unique identifier string.

Throws

on network errors or unexpected responses.

Android (Kotlin) — auto-login after member creation

lifecycleScope.launch {
val ok = AFCore.authentication().loginWithUniqueId(uniqueId = "EMP001")
if (ok) navigateToHome() else showError("Member not found")
}

iOS (Swift) — auto-login after member creation

Task {
do {
let ok = try await AFCore.shared.authentication().signInOrCreateMember(externalUserId: "EMP001")
if ok { navigateToHome() } else { showError("Member not found") }
} catch {
showError("Sign in failed: \\(error.localizedDescription)")
}
}