Dynamic Keys

This guide will cover using Descope's dynamic keys within Descope flows, conditions, messaging templates, etc. Dynamic keys in Descope hold values of attributes regarding the user, device, etc., which users can utilize for various authentication flows. Dynamic keys can be used within Descope conditions, actions, connectors, etc.

Usage

  1. Dynamic keys can be specific items you may want to pass to the email or SMS for the various authentication methods as a part of custom templates. Refer to custom templates here.
  2. These also can be utilized under conditional flows where users can check with values for respective keys to create conditional statements.
  3. You can also use these values to display to the user within the Descope flow screens.

Default Dynamic Keys

Dynamic Keys in Descope belong to a few categories.

User and unauthUser

The user and unauthUser keys load the details of an authenticated user (user) or an unauthenticated user (unauthUser) during the flow execution. The user keys guide provides detailed documentation of these keys.

AuthInfo

  • authInfo : Keys prefixed with authInfo provide authentication related information to the user.
Dynamic KeyDescription
authInfo.sessionJwtA JSON web token used for session authentication and authorization purposes
authInfo.refreshJwtA JSON web token used for obtaining a new sessionJwt after expiration
authInfo.cookieDomainThe domain that the cookie is valid for, used for cross-domain authentication
authInfo.cookiePathThe path that the cookie is valid for, used for limiting cookie access to specific paths
authInfo.cookieMaxAgeThe maximum duration for which the cookie is valid, in seconds
authInfo.cookieExpirationThe date and time at which the cookie expires, used for setting an explicit expiration date
authInfo.firstSeenWhether the user is logging in for the first time

Example of utilizing authInfo Dynamic keys in a flow condition:

AuthInfo Example in Flow

Device

  • device : Key prefixed with device give information with respect to the user's device.
Dynamic KeyDescription
device.location.schemeThe scheme of the URL where the flow is used. Such as http or https.
device.location.uriThe full URI where the flow is used. Such as https://app.domain.com/path?q=v#fragment
device.location.hostnameThe hostname where the flow is used. Such as app.domain.com.
device.location.portThe port where the flow is used. Such as 3000
device.location.pathThe path where the flow is used. Such as /path
device.location.rawQueryThe raw query string where the flow is used. Such as "q=v"
device.location.fragmentThe fragment (the URI part after #) where the flow is used. Such as fragment, in case the full URI is https://app.domain.com#fragment
device.location.queryThe query object where the flow is used. Such as {"q":"v"}
device.webAuthnSupportIndicates whether the device supports Passkeys (Webauthn)

Example of utilizing device Dynamic keys in a flow condition:

Device Key Example in Flow

Form

  • form : Keys prefixed with form are specific to inputs provided by the user while authenticating into their application.
Dynamic KeyDescription
form.emailThe email form input
form.emailDomainThe domain of the email form input
form.phoneThe phone form input
form.photoThe picture uploaded by the "Take Photo" component
form.inviteesThe invitees form input
form.externalIdThe custom login ID form input
form.fullNameThe display name form input
form.firstNameThe given name form input
form.lastNameThe family name form input
form.tenantDomainThe tenant domain form input
form.middleNameThe middle name form input
form.selfProvisionDomainsThe self provision domains form input
form.impersonateIdThe impersonate ID selected from the form input
form.entityIdThe entity ID form input
form.tenantNameThe tenant name form input
form.idpCertThe IdP certificate form input
form.idpMetadataURLThe IdP metadata URL form input
form.idpURLThe IDP URL form input
form.displayNameThe display name form input
form.givenNameThe given name form input
form.familyNameThe family name form input
form.trustThisDeviceMark this device as trusted

Example of utilizing form Dynamic keys in a flow condition:

Form Email Domain Example in Flow

RiskInfo

  • riskInfo : Keys prefixed with riskInfo are specifically used for risked based authentication.
Dynamic KeyDescription
riskInfo.botDetectedIndicates whether a user is likely a bot based on their behavior or activity
riskInfo.riskScoreA numerical value representing the risk score associated with a user's behavior or activity
riskInfo.vpnDetectedIndication of whether the end user is using a VPN
riskInfo.newDeviceIndication of whether the end user is using a device that hasn't been spotted before in your application
riskInfo.trustedDeviceIndication of whether this device has been marked as trusted before or not
riskInfo.impossibleTravelIndication of whether this user has connected from two different countries and the time between those connections can't be made through conventional air travel

Example of utilizing riskInfo Dynamic keys in a flow condition:

Risk Info Example in Flow

Note

For more use cases on using riskInfo key, refer here

UserAgent

  • userAgent : Keys prefixed with userAgent provide details about the system, operating system, host application etc.
Dynamic KeyDescription
userAgent.mobileIs request coming from a mobile device?
userAgent.desktopIs request coming from a PC?
userAgent.deviceDevice type (present for iOS and Android devices)
userAgent.rawRaw User Agent header
userAgent.nameShort agent name
userAgent.osOperating system
userAgent.osVersionOperating system version
userAgent.tabletIs request coming from a Tablet?
userAgent.urlURL provided in case of a bot

Example of utilizing userAgent Dynamic keys in a flow condition:

User Agent Example in Flow

jwtClaims

  • jwtClaims : Keys prefixed with jwtClaims provide post-authentication details that are stored in the JWT response. Please note that these keys will only be available after the user goes through an authentication flow.
Dynamic KeyDescription
jwtClaims.amrIdentifiers Used
jwtClaims.drnType of Token
jwtClaims.expTimestamp of Expiration Time
jwtClaims.issTimestamp of Issued Time
jwtClaims.subUser Id

In addition to the keys above, custom claims on the JWT that are Strings will also be available. They can be accessed as jwtClaims.custom-claim-key.

Example of utilizing jwtClaims Dynamic keys in a flow condition:

jwtClaims Example in Flow

Additional Context Keys

In addition to the default dynamic keys mentioned above, Descope supports keys created by connectors or scriptlets used in flows.

For more information on these, please refer to the following links :

  • Scriptlets : Keys as a result of executing scriptlets in flows are in the format scripts.scriptletResult.xyz where xyz is the variable holding the result of the scriptlet action.
  • Connectors : Keys being returned from connectors are prefixed with connectors..
  • Document : Key used specifically for document being uploaded via flows.

The list of Dynamic Keys is continually expanding, but the guide above provides a solid foundation for understanding how they are used in Descope.

Was this helpful?

On this page