Skip to main content

Custom JWT Authentication

3-4 hours

Unit can rely on a custom implementation of JWT token that adheres to the specifications outlined in RFC 7519.

In this case you should provide Unit with a public key that will be used to validate the token.

The token must be signed using the RS256 algorithm and must include the following claims:

ClaimDescription
subA unique identifier for the end-user
expThe expiration time of the token
issThe issuer of the token

JWT Authentication Troubleshooting:

If you receive an error, ensure the following:

  • You're using the Sandbox (ui.s.unit.sh) or Production (ui.unit.co) script matching your environment.
  • Decode your token. The iss matches the Issuer you configured in the Dashboard and the sub value is a string (stable user id). The token is still valid, with an exp in the future. The header includes alg: RS256 and a valid kid.
  • The Public Key was entered into the Unit Dashboard correctly, and is the correct one for the provided token. The kid in the JWT matches one in your uploaded Public Key or JWKs.
  • The cache has been cleared (localStorage keys unitCustomerToken and unitVerifiedCustomerToken).
  • The jwt-token value is present before the component initializes.