Skip to content

Support session_duration_minutes and session_custom_claims in authenticateJwt - #463

Merged
jlai-stytch merged 2 commits into
mainfrom
jlai/session_duration
Jun 22, 2026
Merged

jlai-stytch merged 2 commits into
mainfrom
jlai/session_duration

Conversation

@jlai-stytch

@jlai-stytch jlai-stytch commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds support for the session_duration_minutes and session_custom_claims params in authenticateJwt() for both B2B and Consumer

This method is manually generated (i.e. not managed by codegen), so I believe this doesn't require changes elsewhere. I ran npm run build.

The logic mirrors the Ruby and Go SDK's logic which currently supports session_duration_minutes as a param: https://github.com/stytchauth/stytch-ruby/blob/32cf1771b62e0b8ac320f6d1d955cc061fd2c888/lib/stytch/b2b_sessions.rb#L628-L678

https://github.com/stytchauth/stytch-go/blob/87c4a9068c1e2dad24acbc151f15b6eb642f86a3/stytch/b2b/sessions.go#L446-L448

  • It'll essentially silently ignore session_duration_minutes if the JWT is verified locally
  • Remote JWT validation can now be forced by passing in max_token_age_seconds = 0

Motivation

Customer request from the community Slack: https://app.plain.com/workspace/w_01HAQ5N757DAG0R7JTXZ4MQYKY/thread/th_01KTS9YSFQJ7KRDEXBJ3NQVA9M/

Our API docs say you can pass in session_duration_minutes to extend a Session's lifetime (when the auth doesn't happen locally): https://stytch.com/docs/api-reference/b2b/api/sessions/authenticate-jwt

but from what I found, only some of our backend SDKs currently support this param today, like Ruby and Go:

Ruby:
https://github.com/stytchauth/stytch-ruby/blob/32cf1771b62e0b8ac320f6d1d955cc061fd2c888/lib/stytch/b2b_sessions.rb#L628-L678

Golang:
https://github.com/stytchauth/stytch-go/blob/87c4a9068c1e2dad24acbc151f15b6eb642f86a3/stytch/b2b/sessions.go#L435-L459

but not Python and Java:

Python:
https://github.com/stytchauth/stytch-python/blob/6987801e7eb03b0c6b34dc46f042e5d532e7299a/stytch/b2b/api/sessions.py#L806-L856

Java:
https://github.com/stytchauth/stytch-java/blob/f85a264f20b2a50132acefbbd27d99c9bd17865c/stytch/src/main/kotlin/com/stytch/java/b2b/api/sessions/Sessions.kt#L458-L471

Action item for the future would be to add this to the rest of the backend SDKs for parity

Testing

  • Added tests

@jlai-stytch
jlai-stytch requested a review from logan-twilio June 10, 2026 18:36
@jlai-stytch
jlai-stytch requested a review from a team as a code owner June 10, 2026 18:36
@jlai-stytch
jlai-stytch force-pushed the jlai/session_duration branch from 54338d3 to dbea80a Compare June 10, 2026 18:48

@logan-twilio logan-twilio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should realistically be a MINOR bump instead of a PATCH since it's adding new functionality

@jlai-stytch
jlai-stytch force-pushed the jlai/session_duration branch from 39dfedc to d36e30e Compare June 22, 2026 23:29
@jlai-stytch
jlai-stytch merged commit 6227cb6 into main Jun 22, 2026
17 of 20 checks passed
@jlai-stytch
jlai-stytch deleted the jlai/session_duration branch June 22, 2026 23:29

This branch had an error being deployed

1 failed deployment
integration_tests — d36e30e4 Deployed Jun 22, 2026 by jlai-stytch via Run Integration Tests (18) #1178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants