Did you follow the quick start instructions to set up the Authenticator first?
Initial State
By default, unauthenticated users are redirected to the Sign In flow. You can explicitly redirect to Sign Up or Forgot Password:
Login Mechanisms
Whether the user is able to sign in with their username, phone number or email is determined based on the value in amplifyconfiguration.json
, which is created on amplify pull
. This value determines which login mechanism Authenticator for Android uses, no other configuration is supported.
Sign Up Attributes
The Authenticator automatically infers signUpAttributes
from amplify pull
,
but can be explicitly defined as seen below.
The Authenticator automatically renders most Cognito User Pools attributes,
with the exception of address
, gender
, locale
, picture
, updated_at
, and zoneinfo
. Because these are often app-specific, they can be customized via Sign Up fields.
By default, the Authenticator will still require any attributes required for
verification, such as email
, even if signUpAttributes
is empty:
val authenticatorState = rememberAuthenticatorState(
signUpForm = {
email()
username()
password()
confirmPassword()
}
)
Authenticator(state = authenticatorState) {
// ...
}
val authenticatorState = rememberAuthenticatorState(
signUpForm = {
username()
password()
confirmPassword()
email()
phoneNumber()
birthdate()
familyName()
givenName()
middleName()
name()
nickname()
preferredUsername()
profile()
website()
}
)
Authenticator(state = authenticatorState) {
// ...
}
TOTP Issuer
The TOTP issuer is the name that will be shown in TOTP applications preceding the account name. In most cases, this should be the name of your app. For example, if your app is called "My App", your user will see "My App" - "username" in their TOTP app. This can be customized by adding the totpOptions
argument to the Authenticator state with a value for issuer
.
Note: Unless changed, the default issuer is the application label retrieved from package manager.
val authenticatorState = rememberAuthenticatorState(
totpOptions = TotpOptions(issuer = "My App")
)
Authenticator(state = authenticatorState) {
// ...
}