Dynamic User Keys

Descope allows you to load data for both authenticated and unauthenticated users. When a user first supplies their login ID (email, phone number, custom login ID, etc.) but has not completed authentication, you can load their details within your flow using the unauthUser dynamic keys. Once the user has completed authentication, you can load their details within your flow using the user dynamic keys.

Custom attributes can be loaded within both user and unauthUser context keys. Example: user.customAttributes.attribute1 or unauthUser.customAttributes.attribute1

User

  • user : Keys prefixed with user is used for authenticated users.
Dynamic KeyDescription
user.userIdA unique identifier for a user
user.loginIdsAll unique identifiers for a user. Usually an email and/or phone
user.nameThe user's name
user.givenNameThe user's given name
user.middleNameThe user's middle name
user.familyNameThe user's family name
user.emailThe user's email address
user.emailDomainThe domain of the user's email address
user.phoneThe user's phone number
user.verifiedEmailWhether the user's email address has been verified
user.verifiedPhoneWhether the user's phone number has been verified
user.userTenantsAn array of tenants associated with the user
user.pictureThe user's picture
user.statusThe user's status including active , invited or disabled
user.tenantNamesAll user tenant names as array
user.tenantIdsAll user tenant IDs as array
user.tenant.rolesThe tenant level user roles
user.fingerprint.knownDeviceIndication of whether the unauthenticated user is using a device that has been spotted before in your application
user.testWill be set to true if this user is a test user
user.lastAuth.countryLast country user logged in from
user.lastAuth.countriesLatest countries user logged in from
user.lastAuth.cityLast city user logged in from
user.lastAuth.citiesLatest cities user logged in from
user.lastAuth.ipLast IP user logged in from
user.lastAuth.ipsLatest IPs user logged in from
user.lastAuth.timeLast time user logged in
user.passwordIndicates whether the user has ever logged in with a password
user.totpIndicates whether user has TOTP set
user.project.rolesAll project level roles associated with this user
user.project.permissionsAll project level permissions associated with this user
user.samlIndicates whether the user has ever logged in with SAML
user.webauthnIndicates whether the user has ever logged in with Passkeys (Webauthn)
user.loggedInIndicates whether the user is already logged in

Example of utilizing user Dynamic keys in a flow condition:

User key Example in Flow

UnauthUser

  • unauthUser : Keys prefixed with unauthUser is used for unauthenticated users.
Dynamic KeyDescription
unauthUser.userIdA unique identifier for a user
unauthUser.loginIdsAll unique identifiers for a user. Usually an email and/or phone
unauthUser.nameThe user's name
unauthUser.givenNameThe user's given name
unauthUser.middleNameThe user's middle name
unauthUser.familyNameThe user's family name
unauthUser.emailThe user's email address
unauthUser.emailDomainThe domain of the user's email address
unauthUser.phoneThe user's phone number
unauthUser.verifiedEmailWhether the user's email address has been verified
unauthUser.verifiedPhoneWhether the user's phone number has been verified
unauthUser.userTenantsAn array of tenants associated with the user
unauthUser.pictureThe user's picture
unauthUser.statusThe user's status including active , invited or disabled
unauthUser.tenantNamesAll user tenant names as array
unauthUser.tenantIdsAll user tenant IDs as array
unauthUser.tenant.rolesThe tenant level user roles
unauthUser.fingerprint.knownDeviceIndication of whether the unauthenticated user is using a device that has been spotted before in your application
unauthUser.testWill be set to true if this user is a test user
unauthUser.lastAuth.countryLast country user logged in from
unauthUser.lastAuth.countriesLatest countries user logged in from
unauthUser.lastAuth.cityLast city user logged in from
unauthUser.lastAuth.citiesLatest cities user logged in from
unauthUser.lastAuth.ipLast IP user logged in from
unauthUser.lastAuth.ipsLatest IPs user logged in from
unauthUser.lastAuth.timeLast time user logged in
unauthUser.passwordIndicates whether the user has ever logged in with a password
unauthUser.totpIndicates whether user has TOTP set
unauthUser.project.rolesAll project level roles associated with this user
unauthUser.project.permissionsAll project level permissions associated with this user
unauthUser.samlIndicates whether the user has ever logged in with SAML
unauthUser.webauthnIndicates whether the user has ever logged in with Passkeys (Webauthn)

Example of utilizing unauthUser Dynamic keys in a flow condition:

UnauthUser key Example in Flow

Further Variations of unauthUser

By default, when using unauthUser context keys, the user is loaded by email; however, there may be scenarios where the user needs to be loaded by another variation. Descope supports loading unauthenticated users using unauthUser.byEmail (default), unauthUser.byPhone, and unauthUser.byTenant.

unauthUser.byEmail

In most scenarios, you'll want to load the unauthenticated user by email after the user has supplied their email address within a Descope flow screen. This is the default behavior, but if you would like to load the user this way, you can use any of the above unauthUser keys like: unauthUser.byEmail.name

unauthUser.byPhone

Suppose you are using the phone number of a user within a flow rather than an email. In that case, you can utilize the unauthUser.byPhone to load user details before authenticating the user. You can use any of the above unauthUser keys like: unauthUser.byPhone.name

unauthUser.byTenant

If you are loading an unauthenticated user that's associated to a SAML tenant, you will likely want to capture details of that user within the flow, and since the user's login ID is something like email-tenantId (me@email.com-txxxx), you'll need to load the user by tenant. You can use any of the above unauthUser keys like: unauthUser.byTenant.name

Was this helpful?

On this page