Reconcile a JWT Using the External JWT Provider API
On this page
The Reconcile API logs in a user with a JWT that an external system issued. FusionAuth validates the JWT with an External JWT Identity Provider, then reconciles the user that the JWT represents. FusionAuth creates or updates the user, depending on the linking strategy of the Identity Provider.
The Reconcile API takes the same request and returns the same response as Complete the External JWT Login. The Reconcile API accepts only External JWT Identity Providers.
The External JWT Identity Provider works only through the API. The FusionAuth hosted login pages don't support the External JWT Identity Provider.
When FusionAuth has an Identity Provider for your provider, such as Facebook, or a generic one, such as OpenID Connect, use that Identity Provider and the /api/identity-provider/login endpoint instead.
When createRegistration is enabled for the Application in the Identity Provider, FusionAuth registers a user who has no RegistrationThe association between a User and an Application. for the Application. FusionAuth then assigns the default roles of the Application. When createRegistration is disabled, FusionAuth doesn't register the user, and the response has a 202 status code.
Request#
Send the JWT in data.token.
OpenAPI Spec
Request Headers#
X-Forwarded-ForThe IP address of the client that requests authentication. When FusionAuth has an IP address, FusionAuth stores the IP address in the login record of the user. When the request body includes ipAddress, FusionAuth uses the request body value instead of this header. Prefer the request body.
X-FusionAuth-TenantIdThe unique Id of the tenant used to scope this API request.
The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.
Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.
See Making an API request using a Tenant Id for additional information.
Request Body#
applicationIdThe Id of the Application the user logs in to. The Application must have External JWT login enabled.
data.token The encoded JWT that the external system issued for the user. FusionAuth validates the JWT signature with the verification keys of the Identity Provider, then reconciles the user from the JWT claims.
data.refresh_token A refresh token from the external system. FusionAuth stores the value in the token field of the user's link to the Identity Provider. For more information, see the Link API.
encodedJWTAn alias for data.token. Send the JWT in either field.
eventInfoInformation about the request. FusionAuth adds the information to the events the request triggers, as event.info. For more information, see Pass Context From API Requests to Webhooks.
eventInfo.data An object that holds any JSON you choose, such as a trace Id. FusionAuth copies the object to event.info.data without changes.
eventInfo.deviceDescription A description of the end user's device. When this value is omitted, FusionAuth uses metaData.device.description.
eventInfo.deviceName The name of the end user's device. When this value is omitted, FusionAuth uses metaData.device.name.
eventInfo.deviceType The type of the end user's device. When this value is omitted, FusionAuth uses metaData.device.type.
eventInfo.ipAddress The IP address of the end user. When your server calls FusionAuth for the end user, set this value to the end user's IP address. When this value is omitted, FusionAuth uses ipAddress. When both values are omitted, FusionAuth uses the IP address of the client that sent the request.
eventInfo.os The operating system of the end user's device.
eventInfo.userAgent The user agent of the end user's browser.
identityProviderIdThe unique Id of the Identity Provider that processes the login request.
connectionTestIdThe Id of a connection test, which the Start an Identity Provider Connection Test API returns. For more information, see Start an Identity Provider Connection Test.
ipAddressThe IP address of the end user who logs in. When you leave out ipAddress, FusionAuth uses the X-Forwarded-For header, or the address of the last proxy that sent the request. FusionAuth stores the IP address in the user's login history.
metaData.device.description A human-readable description of the device.
metaData.device.lastAccessedAddress The IP address of the login request.
metaData.device.name A human-readable name of the device.
metaData.device.type The type of device. In 1.46.0 and later, the value can be any string. Before 1.46.0, the value must be one of the following types:
BROWSERDESKTOPLAPTOPMOBILEOTHERSERVERTABLETTVUNKNOWN
newDeviceWhether the user has never logged in from the device. FusionAuth uses the value as one signal when deciding whether to issue an MFA challenge for Intelligent MFA or the MFA Requirement Lambda. When true, FusionAuth also sends the New Device Webhook.
noJWTWhen true, FusionAuth doesn't issue a JWT. The response body has no token field, and FusionAuth doesn't write the access_token and refresh_token cookies.
When you send many login requests and don't use the JWT, set noJWT to true. FusionAuth then skips signing JWTs.
noLinkWhen true and no link to a FusionAuth user exists, FusionAuth returns a 404 status code instead of applying the linking strategy. Use noLink to check for a link before you start an interactive linking workflow with the user.
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODUxNDA5ODQsImlhdCI6MTQ4NTEzNzM4NCwiaXNzIjoiYWNtZS5jb20iLCJzdWIiOiIyOWFjMGMxOC0wYjRhLTQyY2YtODJmYy0wM2Q1NzAzMThhMWQiLCJhcHBsaWNhdGlvbklkIjoiNzkxMDM3MzQtOTdhYi00ZDFhLWFmMzctZTAwNmQwNWQyOTUyIiwicm9sZXMiOltdfQ.Mp0Pcwsz5VECK11Kf2ZZNF_SMKu5CgBeLN9ZOP04kZo"
},
"identityProviderId": "7a9ed2eb-13e7-424a-b416-c9392c7192a1",
"ipAddress": "192.168.1.42"
}Response#
The response contains the User object.
| Code | Description |
|---|---|
| 200 | The authentication succeeded. The response contains the authenticated User object. |
| 202 | The authentication succeeded, but the user isn't registered for the Application in the The response contains the authenticated User object. |
| 203 | The authentication succeeded, but the user must change the password. The response contains the |
| 204 | The login waits on an action by the user. Wait, and then send the request again. |
| 212 | The identity that the user logged in with, such as an email address or phone number, isn't verified yet. The response contains the authenticated User object. When the verification strategy is |
| 213 | The Registration of the user isn't verified yet. The response contains the authenticated User object. When the verification strategy is Before version |
| 232 | The Identity Provider uses the |
| 242 | The authentication succeeded, and the user has two-factor authentication enabled. In |
| 400 | The request was invalid or malformed, or a login validation lambda rejected the login. The response contains an Errors JSON object with the specific errors. |
| 401 | FusionAuth couldn't complete the login. For example, the Identity Provider isn't enabled for the Application, FusionAuth couldn't verify the response from the Identity Provider, or FusionAuth couldn't reconcile the user. |
| 404 | FusionAuth didn't find the user, or no Link to the user exists and either the linking strategy is |
| 409 | An action on the user prevents login. The response contains the actions that prevent login. |
| 410 | The user has expired. The response is empty. |
| 500 | FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty. |
| 503 | The search index is unavailable or returned an error, so FusionAuth can't complete the request. The response contains a JSON body. |
| 504 | One or more webhook endpoints returned an invalid response or were unreachable. Because of the transaction configuration for the event, FusionAuth can't complete the request. FusionAuth logs a stack trace in the FusionAuth log files. |
When the applicationId or the identityProviderId doesn't exist, the response has a 400 status code. The response also has a 400 status code when the identityProviderId belongs to an Identity Provider of another type.
Login Failures#
FusionAuth returns a 401 for the following causes:
- FusionAuth can't validate the JWT signature.
- The JWT is missing a claim that the Identity Provider configuration requires. FusionAuth always requires the unique Id claim. When the linking strategy links on the email claim or the username claim, FusionAuth also requires that claim.
- The email verified claim is
false, and the linking strategy links on email. - The email address isn't in a domain that the Identity Provider manages.
- The linking strategy is
LinkByEmailForExistingUser, and no user has the email address. - The linking strategy links on email, and the user with the email address already has a link to the IdP with a different unique Id.
Response Body#
emailVerificationIdAn email verification Id, which is needed when performing your own email verification using the /api/user/verify-email API.
This field is only returned when the tenant.emailConfiguration.verificationStrategy is set to FormField.
identityVerificationIdAn identity verification Id, which is needed when performing your own identity verification using the /api/identity/verify API.
This field is only returned under the following conditions, based on the identity that was used to log in:
- An email address - the tenant.emailConfiguration.verificationStrategy is set to
FormField. - A phone number - the tenant.phoneConfiguration.verificationStrategy is set to
FormField.
refreshTokenThe refresh token that can be used to obtain a new access token once the provided one has expired.
Because a refresh token is per user and per application, this value will only be returned when an applicationId was provided on the login request and the user is registered to the application.
You must explicitly allow generation of refresh tokens when using the Login API.
Configure the application.loginConfiguration.generateRefreshTokens setting via the API or enable the setting by navigating to the Application -> My Application -> Security tab.
refreshTokenIdWhen the refreshToken is returned in the response, this field will also be returned. This unique Id is the persistent identifier for this refresh token, and will not change even when using one-time use refresh tokens. This value may optionally be used to revoke the token using the Refresh Token API.
stateIf authenticated using a One Time Password and state was provided during the Change Password request this value will be returned exactly as it was provided.
threatsDetectedThe authentication threats FusionAuth detected for the login. FusionAuth only detects threats with Advanced Threat Detection. Currently, FusionAuth only returns ImpossibleTravel, when the impossible travel risk is high. To receive the other threats, listen for the Suspicious Login event.
tokenThe access token, this string is an encoded JSON Web Token (JWT).
When the user will be sent a setup password email or sms message, this token will not be returned.
tokenExpirationInstantThe instant the token will expire. If the response does not contain a token, this field will also be omitted from the response.
user.active True if the User is active. False if the User has been deactivated. Deactivated Users will not be able to log in.
user.birthDate The User's birthdate formatted as YYYY-MM-DD
user.breachedPasswordLastCheckedInstant The instant this user's password was last checked to determine if it is compromised.
user.connectorId The unique Id of the Connector associated with the System of Record being used to authenticate the user.
user.cleanSpeakId This Id is used by FusionAuth when the User's username is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
user.data An object that can hold any information about the User that should be persisted.
user.data.email This field will be used as the email address if no user.email field is found.
This feature was removed in version 1.26.0 and added back in 1.27.2.
user.email The User's email address.
user.expiry The expiration instant of the User's account. An expired user is not permitted to log in.
user.firstName The first name of the User.
user.fullName The User's full name as a separate field that is not calculated from firstName and lastName.
user.id The User's unique Id.
user.identities The list of identities that exist for a User.
user.identities[x].displayValue The display value for the identity. Only used for username type identities. If the unique username feature is not enabled, this value
will be the same as user.identities[x].value. Otherwise, it will be the username the User has chosen. For
primary username identities, this will be the same value as user.username.
user.identities[x].insertInstant The instant when the identity was created.
user.identities[x].lastLoginInstant The instant when the identity was last used to log in. If a User has multiple identity types (username, email, and phoneNumber), then this value will represent the specific identity they last used to log in. This contrasts with user.lastLoginInstant, which represents the last time any of the User's identities was used to log in.
Identity provider logins will not be reflected here (see user.lastLoginInstant for a field that includes identity provider logins).
user.identities[x].lastUpdateInstant The instant when the identity was last updated.
user.identities[x].moderationStatus The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
ACTIVE- the username is activePENDING- the username is pending approval/moderationREJECTED- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
Only used for username type identities. For primary username identities, this will be the same value as user.usernameStatus.
user.identities[x].type The identity type. The possible values are:
email- identities defined by an email addressphoneNumber- identities defined by a phone numberusername- identities defined by a username
user.identities[x].value The value represented by the identity. The contents of this field depend on user.identities[x].typeand will be one of the following:
- Email address - The User's email address, always lower cased. For primary email identities, this will be the same value as user.email
- Phone number - The User's phone number, in E.164 canonical format. For primary phone number identities, this will be the same value as user.phoneNumber
- Username - User's username - this will be the same as user.identities[x].displayValue. For primary username identities, this will be the same value as user.username
This value is unique within a tenant for a particular user.identities[x].type.
If the unique usernames feature is enabled, value will be the unique username (within the tenant). For primary username identities, this will also be the same value as user.uniqueUsername.
user.identities[x].verified Whether verification was actually performed on the identity by FusionAuth. This is used in combination with the user.identities[x].verifiedReason to decide whether an identity needs verification.
user.identities[x].verifiedInstant The instant when verification was performed on the identity. This field is only populated when verification was actually performed on the identity by FusionAuth.
user.identities[x].verifiedReason The reason the User's identity was verified or not verified. The possible values are:
Skipped- Verification was skipped due to theskipVerificationparameter on the requestTrusted- Identity was created via an identity provider or a connectorUnverifiable- FusionAuth doesn't know how to verify this identity type. Usernames are an exampleImplicit- Verification was implicitly performed when the user completed another workflow that FusionAuth sent to the identity, such as set password, forgot password, or passwordless loginPending- Tenant policy requires verification but no verification has been performed yetCompleted- Verification was performed by FusionAuthDisabled- Tenant policy did not require verificationImport- User was imported so verification was not performed by FusionAuth
If this field is Disabled, Import, Skipped, Trusted, or Unverifiable, then verification will not be required, regardless of the user.identities[x].verified value.
For Implicit, Pending, or Completed, the identity will require verification if user.identities[x].verified is false.
user.imageUrl The URL that points to an image file that is the User's profile image.
user.insertInstant The instant when the user was created.
user.lastLoginInstant The instant when the User logged in last. See user.identities[x].lastLoginInstant for more granular information based on identity.
user.lastName The User's last name.
user.lastUpdateInstant The instant when the User was last updated.
user.legacyIdentifier Used to override the sub claim in tokens issued by the Legacy Identity Provider Adapter.
This value is immutable after the user is created and is unique within the tenant when non-null.
user.memberships The list of memberships for the User.
user.memberships[x].data An object that can hold any information about the User for this membership that should be persisted.
user.memberships[x].groupId The Id of the Group of this membership.
user.memberships[x].id The unique Id of this membership.
user.memberships[x].insertInstant The instant that the membership was created.
user.middleName The User's middle name.
user.mobilePhone The User's mobile phone number. This is useful if you will be sending push notifications or SMS messages to the User.
This differs from user.phoneNumber and cannot be used to log in.
user.parentEmail The email address of the user's parent or guardian. If this value was provided during a create or update operation, this value will only remain until the child is claimed by a parent.
user.passwordChangeRequired Indicates that the User's password needs to be changed during their next login attempt.
user.passwordLastUpdateInstant The instant that the User last changed their password.
Since version 1.59.0, if a user does not currently have a password, this field will not be returned in the response.
user.phoneNumber The User's primary phone number. The phone number is stored and returned in E.164 canonical format, however a phone number is considered unique regardless of the format. 303-555-1212 is considered equal to +13035551212 so either version of this phone number can be used whenever providing it as input to an API.
This differs from user.mobilePhone in that user.phoneNumber can be used to log in, in the same way as an email address or a username.
user.preferredLanguages An array of locale strings that give, in order, the User's preferred languages. These are important for email templates and other localizable text. See Locales.
user.registrations The list of registrations for the User. This will include registrations for inactive applications.
user.registrations[x].applicationId The Id of the Application that this registration is for.
user.registrations[x].authenticationToken The Authentication Token for this registration (if one exists).
user.registrations[x].cleanSpeakId This Id is used by FusionAuth when the User's username for this registration is sent to CleanSpeak to be moderated (filtered and potentially sent to the approval queue). It is the content Id of the username inside CleanSpeak.
user.registrations[x].data An object that can hold any information about the User for this registration that should be persisted.
user.registrations[x].id The Id of this registration.
user.registrations[x].insertInstant The instant that this registration was created.
user.registrations[x].lastLoginInstant The instant that the User last logged into the Application for this registration.
user.registrations[x].preferredLanguages An array of locale strings that give, in order, the User's preferred languages for this registration. These are important for email templates and other localizable text.
user.registrations[x].roles The list of roles that the User has for this registration. The string is the role's Name not the role's Id, e.g. admin or user-role.
user.registrations[x].timezone The User's preferred timezone for this registration. The string will be in an IANA time zone format.
user.registrations[x].tokens A map that contains tokens returned from identity providers.
For example, if this user has authenticated using the Facebook Identity Provider, the Facebook access token will be available in this map, keyed by name Facebook. For an OpenID Connect Identity provider, or other generic providers, if a token is stored it will be keyed by the Identity Provider unique Id.
1.28.0The token returned and stored from the Identity Provider is now stored in the IdP link and is retrievable using the Identity Provider Link API.
user.registrations[x].username The username of the User for this registration only. This is for display purposes and cannot be used to log in.
user.registrations[x].usernameStatus The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
ACTIVE- the username is activePENDING- the username is pending approval/moderationREJECTED- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
user.registrations[x].verified Whether the User has verified this registration. When the Application has application.verifyRegistration set to true, a new registration starts as false and changes to true after the User completes registration verification. Otherwise, a new registration starts as true.
Registration verification is separate from email verification. user.verified reports email verification. Verifying a registration also verifies the User's primary email address when FusionAuth sent the registration verification email and the Tenant has tenant.emailConfiguration.implicitEmailVerificationAllowed set to true.
For additional information, see these tutorials:
user.registrations[x].verifiedInstant The instant that this registration was verified.
user.tenantId The Id of the Tenant that this User belongs to.
user.timezone The User's preferred timezone. This can be used as a default to display instants, and it is recommended that you allow Users to change this per-session. The string will be in an IANA time zone format.
user.twoFactor.methods[x].authenticator.algorithm The algorithm used by the TOTP authenticator. With the current implementation, this will always be HmacSHA1.
user.twoFactor.methods[x].authenticator.codeLength The length of code generated by the TOTP. With the current implementation, this will always be 6.
user.twoFactor.methods[x].authenticator.timeStep The time-step size in seconds. With the current implementation, this will always be 30.
user.twoFactor.methods[x].email The value of the email address for this method. Only present if user.twoFactor.methods[x].method is email.
user.twoFactor.methods[x].id The unique Id of the method.
user.twoFactor.methods[x].lastUsed true if this method was used most recently.
user.twoFactor.methods[x].method The type of this method. There will also be an object with the same value containing additional information about this method. The possible values are:
authenticatoremailsms
user.twoFactor.methods[x].mobilePhone The value of the mobile phone for this method. Only present if user.twoFactor.methods[x].method is sms.
user.twoFactorDelivery The User's preferred delivery for verification codes during a two-factor login request.
The possible values are:
NoneTextMessage
1.26.0user.twoFactorEnabled Determines if the User has two-factor authentication enabled for their account or not.
Removed in1.26.0user.username The username of the User.
user.usernameStatus The current status of the username. This is used if you are moderating usernames via CleanSpeak. The possible values are:
ACTIVE- the username is activePENDING- the username is pending approval/moderationREJECTED- the username was rejected during moderation
If a username has been rejected, it is still possible to allow the User to update it and have the new one moderated again.
user.verified Whether the User's primary email address is verified or exempt from verification. When the User has no email address, this field reports the username instead. Phone numbers never affect this field. To check the verification status of a phone number, use user.identities[x].verified and user.identities[x].verifiedReason.
For additional information, see these tutorials:
1.59.0See user.identities[x].verified and user.identities[x].verifiedReason.
user.verifiedInstant The first instant that the User's primary email address or phone number was verified. This value is immutable and cannot change for a user once set.
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODUxNDA5ODQsImlhdCI6MTQ4NTEzNzM4NCwiaXNzIjoiYWNtZS5jb20iLCJzdWIiOiIyOWFjMGMxOC0wYjRhLTQyY2YtODJmYy0wM2Q1NzAzMThhMWQiLCJhcHBsaWNhdGlvbklkIjoiNzkxMDM3MzQtOTdhYi00ZDFhLWFmMzctZTAwNmQwNWQyOTUyIiwicm9sZXMiOltdfQ.Mp0Pcwsz5VECK11Kf2ZZNF_SMKu5CgBeLN9ZOP04kZo",
"user": {
"active": true,
"birthDate": "1976-05-30",
"breachedPasswordLastCheckedInstant": 1471786483322,
"breachedPasswordStatus": "None",
"connectorId": "e3306678-a53a-4964-9040-1c96f36dda72",
"data": {
"displayName": "Johnny Boy",
"favoriteColors": [
"Red",
"Blue"
]
},
"email": "example@fusionauth.io",
"expiry": 1571786483322,
"firstName": "John",
"fullName": "John Doe",
"id": "00000000-0000-0001-0000-000000000000",
"identities": [
{
"insertInstant": 1742936980069,
"lastLoginInstant": 1742936980069,
"lastUpdateInstant": 1742936980069,
"primary": true,
"type": "email",
"value": "example@fusionauth.io",
"verified": false,
"verifiedReason": "Disabled"
},
{
"insertInstant": 1742936980069,
"lastLoginInstant": 1742936980069,
"lastUpdateInstant": 1742936980069,
"primary": true,
"type": "phoneNumber",
"value": "+13035551212",
"verified": false,
"verifiedReason": "Disabled"
},
{
"displayValue": "johnny123",
"insertInstant": 1742936980069,
"lastLoginInstant": 1742936980069,
"lastUpdateInstant": 1742936980069,
"moderationStatus": "ACTIVE",
"primary": true,
"type": "username",
"value": "johnny123",
"verified": false,
"verifiedReason": "Unverifiable"
}
],
"imageUrl": "http://65.media.tumblr.com/tumblr_l7dbl0MHbU1qz50x3o1_500.png",
"insertInstant": 1742936980069,
"lastLoginInstant": 1742936980069,
"lastName": "Doe",
"middleName": "William",
"mobilePhone": "303-555-1234",
"passwordChangeRequired": false,
"passwordLastUpdateInstant": 1742936980069,
"phoneNumber": "+13035551212",
"preferredLanguages": [
"en",
"fr"
],
"registrations": [
{
"applicationId": "10000000-0000-0002-0000-000000000001",
"data": {
"displayName": "Johnny",
"favoriteSports": [
"Football",
"Basketball"
]
},
"id": "00000000-0000-0002-0000-000000000000",
"insertInstant": 1742936980069,
"lastLoginInstant": 1742936980069,
"preferredLanguages": [
"en",
"fr"
],
"roles": [
"user",
"community_helper"
],
"username": "johnny123",
"usernameStatus": "ACTIVE",
"verified": true,
"verifiedInstant": 1742936980069
}
],
"timezone": "America/Denver",
"tenantId": "f24aca2b-ce4a-4dad-951a-c9d690e71415",
"twoFactor": {
"methods": [
{
"authenticator": {
"algorithm": "HmacSHA1",
"codeLength": 6,
"timeStep": 30
},
"id": "35VW",
"method": "authenticator"
},
{
"id": "V7SH",
"method": "sms",
"mobilePhone": "555-555-5555"
},
{
"email": "example@fusionauth.io",
"id": "7K2G",
"method": "email"
}
]
},
"usernameStatus": "ACTIVE",
"username": "johnny123",
"verified": true,
"verifiedInstant": 1742936980069
}
}Response Cookies#
access_tokenThe access token, an encoded JSON Web Token (JWT). FusionAuth writes the access token as an HTTP-only session cookie.
refresh_tokenThe refresh token. FusionAuth writes the refresh token as an HTTP-only persistent cookie. The cookie lasts as long as the refresh token time to live in the JWT configuration of the Tenant. When the Application enables its own JWT configuration, the time to live of the Application applies instead.
Related
Learn about the APIs that allow you to manage Refresh Tokens, verify Access Tokens and retrieve public keys used for verifying JWT signatures.
API documentation for the FusionAuth Issue a JWT API.
API documentation for the FusionAuth Refresh a JWT API.
API documentation for the FusionAuth Retrieve Public Keys API.