Verify JWT
Verify a JWT signed with a DigitalGenius API secret and return its claims.
What it does
- Verifies a JWT signed with the API secret of your DigitalGenius connection.
- Checks the signature of the token, and its expiry when the token has an
expclaim. - Returns whether the token is verified, and the token's claims when it is.
- Authenticates with your DigitalGenius connection, so you don't need to pass a DG API Key and Secret.
Use this action to confirm that data passed into a flow comes from a trusted source. For example, your website signs a token with your DigitalGenius API secret for a logged-in customer. The flow then verifies the token and reads the customer details from the claims.
Inputs
| Name | Type | Description |
|---|---|---|
| JWT | String | The token to verify. It must be signed with HS256 using the API secret of the DigitalGenius connection. Select the DigitalGenius connection whose key and secret sign the tokens. We recommend an exp claim, which the action checks when present. We also recommend a kid header set to the connection's API key. |
| Safe Mode | Optional Boolean | When true, the action returns Success as false with an error message instead of raising an error when the connection is missing or invalid. Defaults to false. |
Outputs
| Name | Type | Description |
|---|---|---|
| Success | Boolean | Whether the action ran. False when Safe Mode is on and the connection is missing or invalid. |
| Verified | Boolean | Whether the token's signature is valid and, when the token has an exp claim, the token has not expired. |
| Claims | Object | The token's payload when Verified is true. Empty otherwise. |
| Error Message | String | Why the token was not verified. For example, the token has expired or the signature is invalid. Empty when Verified is true. |
Signing the token
Sign the token with the following settings:
- Algorithm: HS256. The action rejects tokens signed with any other algorithm, including unsigned tokens.
- Secret: the API secret of the DigitalGenius connection used by the action.
expclaim: recommended. The action rejects the token after this expiry time. A token without anexpclaim never expires, so set a short expiry to limit how long a token stays valid.kidheader: recommended. Set it to the API key of the DigitalGenius connection. If you set it to a different key, the action rejects the token.
The action also checks the nbf and iat claims when they are present. It allows 30 seconds of clock difference between the token issuer and DigitalGenius.
Notes
- The action needs a DigitalGenius connection. It reads the API key and secret from the connection.
- An invalid token doesn't raise an error. The action returns Success as true, Verified as false, and the reason in Error Message. Use Verified to branch the flow, for example when a visitor isn't logged in.
- If the JWT input is empty, the action returns Verified as false with the error message
JWT is required. - The action ignores whitespace around the token.
- Common error messages for a rejected token include
Signature has expired,Signature verification failed,Token was signed for a different API key, andThe specified alg value is not allowed. - If the DigitalGenius connection is missing or invalid, the action raises an error, even when the JWT input is empty. Turn on Safe Mode to handle the failure in the flow with the Success and Error Message outputs instead.
- The action doesn't write the token, the claims, or the connection credentials to the logs.
- To verify a token signed with a public key set, use Verify JWT Token with JWKs.
Updated about 7 hours ago
Did this page help you?
