Authenticate a session using a JSON Web Token (JWT)
session_duration_minutes. If session_duration_minutes is not specified, the Session will not be extended.
exp claim, a new JWT will be returned if both the signature and the underlying Session are still valid. See our JWT guides for more information.
If the JWT is older than max_token_age_seconds or if the JWT is expired, this method will communicate with the Stytch API to authenticate the session. Otherwise, the JWT will be validated locally.
max_token_age_seconds parameter, then the authenticateJwt method will only communicate with the Stytch API if the JWT is expired (Stytch JWTs have an exp of five minutes). Specifying a max_token_age_seconds parameter of less than five minutes is one way to reduce security risks inherent to local JWT validation by forcing communication with the Stytch API more frequently.
We recommend relying primarily on this method over the authenticateSession method, as it handles the local JWT validation vs. remote session authentication logic for you, improving latency when the JWT is less than max_token_age_seconds old and authenticating the underlying session with Stytch when necessary.
authorization_check is passed in, this method will also check if the is authorized to perform the given action on the given Resource in the specified . A Member is authorized if:
organization_id passed in the authorization check matches Member Session’s Organization.403 error will be thrown. Otherwise, the response will contain a list of Roles that satisfied the authorization check.
organization_id passed in the authorization check must match the Member’s Organization.iat claim).authorization_check is provided in the request and the check succeeds, this field will return information about why the Member was granted permission.