You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: stytch/consumer/api/sessions.py
+56-12Lines changed: 56 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -298,7 +298,9 @@ def exchange_access_token(
298
298
"""Use this endpoint to exchange a Connected Apps Access Token back into a Stytch Session for the underlying User.
299
299
This session can be used with the Stytch SDKs and APIs.
300
300
301
-
The Access Token must contain the `full_access` scope and must not be more than 5 minutes old. Access Tokens may only be exchanged a single time.
301
+
The Session returned will be the same Session that was active in your application (the authorizing party) during the initial authorization flow.
302
+
303
+
The Access Token must contain the `full_access` scope (only available to First Party clients) and must not be more than 5 minutes old. Access Tokens may only be exchanged a single time.
302
304
303
305
Fields:
304
306
- access_token: The access token to exchange for a Stytch Session. Must be granted the `full_access` scope.
"""Use this endpoint to exchange a Connected Apps Access Token back into a Stytch Session for the underlying User.
338
340
This session can be used with the Stytch SDKs and APIs.
339
341
340
-
The Access Token must contain the `full_access` scope and must not be more than 5 minutes old. Access Tokens may only be exchanged a single time.
342
+
The Session returned will be the same Session that was active in your application (the authorizing party) during the initial authorization flow.
343
+
344
+
The Access Token must contain the `full_access` scope (only available to First Party clients) and must not be more than 5 minutes old. Access Tokens may only be exchanged a single time.
341
345
342
346
Fields:
343
347
- access_token: The access token to exchange for a Stytch Session. Must be granted the `full_access` scope.
@@ -373,13 +377,13 @@ def get_jwks(
373
377
) ->GetJWKSResponse:
374
378
"""Get the JSON Web Key Set (JWKS) for a project.
375
379
376
-
JWKS are rotated every ~6 months. Upon rotation, new JWTs will be signed using the new key, and both keys will be returned by this endpoint for a period of 1 month.
380
+
Within the JWKS, the JSON Web Keys are rotated every ~6 months. Upon rotation, new JWTs will be signed using the new key, and both keys will be returned by this endpoint for a period of 1 month.
377
381
378
-
JWTs have a set lifetime of 5 minutes, so there will be a 5 minute period where some JWTs will be signed by the old JWKS, and some JWTs will be signed by the new JWKS. The correct JWKS to use for validation is determined by matching the `kid` value of the JWT and JWKS.
382
+
JWTs have a set lifetime of 5 minutes, so there will be a 5 minute period where some JWTs will be signed by the old keys, and some JWTs will be signed by the new keys. The correct key to use for validation is determined by matching the `kid` value of the JWT and key.
379
383
380
-
If you're using one of our [backend SDKs](https://stytch.com/docs/sdks), the JWKS rotation will be handled for you.
384
+
If you're using one of our [backend SDKs](https://stytch.com/docs/b2b/sdks), the JSON Web Key (JWK) rotation will be handled for you.
381
385
382
-
If you're using your own JWT validation library, many have built-in support for JWKS rotation, and you'll just need to supply this API endpoint. If not, your application should decide which JWKS to use for validation by inspecting the `kid` value.
386
+
If you're using your own JWT validation library, many have built-in support for JWK rotation, and you'll just need to supply this API endpoint. If not, your application should decide which JWK to use for validation by inspecting the `kid` value.
383
387
384
388
See our [How to use Stytch Session JWTs](https://stytch.com/docs/guides/sessions/using-jwts) guide for more information.
385
389
@@ -401,13 +405,13 @@ async def get_jwks_async(
401
405
) ->GetJWKSResponse:
402
406
"""Get the JSON Web Key Set (JWKS) for a project.
403
407
404
-
JWKS are rotated every ~6 months. Upon rotation, new JWTs will be signed using the new key, and both keys will be returned by this endpoint for a period of 1 month.
408
+
Within the JWKS, the JSON Web Keys are rotated every ~6 months. Upon rotation, new JWTs will be signed using the new key, and both keys will be returned by this endpoint for a period of 1 month.
405
409
406
-
JWTs have a set lifetime of 5 minutes, so there will be a 5 minute period where some JWTs will be signed by the old JWKS, and some JWTs will be signed by the new JWKS. The correct JWKS to use for validation is determined by matching the `kid` value of the JWT and JWKS.
410
+
JWTs have a set lifetime of 5 minutes, so there will be a 5 minute period where some JWTs will be signed by the old keys, and some JWTs will be signed by the new keys. The correct key to use for validation is determined by matching the `kid` value of the JWT and key.
407
411
408
-
If you're using one of our [backend SDKs](https://stytch.com/docs/sdks), the JWKS rotation will be handled for you.
412
+
If you're using one of our [backend SDKs](https://stytch.com/docs/b2b/sdks), the JSON Web Key (JWK) rotation will be handled for you.
409
413
410
-
If you're using your own JWT validation library, many have built-in support for JWKS rotation, and you'll just need to supply this API endpoint. If not, your application should decide which JWKS to use for validation by inspecting the `kid` value.
414
+
If you're using your own JWT validation library, many have built-in support for JWK rotation, and you'll just need to supply this API endpoint. If not, your application should decide which JWK to use for validation by inspecting the `kid` value.
411
415
412
416
See our [How to use Stytch Session JWTs](https://stytch.com/docs/guides/sessions/using-jwts) guide for more information.
413
417
@@ -432,6 +436,26 @@ def attest(
432
436
session_token: Optional[str] =None,
433
437
session_jwt: Optional[str] =None,
434
438
) ->AttestResponse:
439
+
"""Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted Auth Token profile in the Stytch dashboard [here](https://stytch.com/docs/dashboard/trusted-auth-tokens). If a session token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing session.
440
+
441
+
Fields:
442
+
- profile_id: The ID of the trusted auth token profile to use for attestation.
443
+
- token: The trusted auth token to authenticate.
444
+
- session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
445
+
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
446
+
five minutes regardless of the underlying session duration, and will need to be refreshed over time.
447
+
448
+
This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
449
+
450
+
If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
451
+
452
+
If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
453
+
- session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
454
+
455
+
Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.
456
+
- session_token: The `session_token` for the session that you wish to add the trusted auth token authentication factor to.
457
+
- session_jwt: The `session_jwt` for the session that you wish to add the trusted auth token authentication factor to.
458
+
"""# noqa
435
459
headers: Dict[str, str] = {}
436
460
data: Dict[str, Any] = {
437
461
"profile_id": profile_id,
@@ -459,6 +483,26 @@ async def attest_async(
459
483
session_token: Optional[str] =None,
460
484
session_jwt: Optional[str] =None,
461
485
) ->AttestResponse:
486
+
"""Exchange an auth token issued by a trusted identity provider for a Stytch session. You must first register a Trusted Auth Token profile in the Stytch dashboard [here](https://stytch.com/docs/dashboard/trusted-auth-tokens). If a session token or session JWT is provided, it will add the trusted auth token as an authentication factor to the existing session.
487
+
488
+
Fields:
489
+
- profile_id: The ID of the trusted auth token profile to use for attestation.
490
+
- token: The trusted auth token to authenticate.
491
+
- session_duration_minutes: Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
492
+
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
493
+
five minutes regardless of the underlying session duration, and will need to be refreshed over time.
494
+
495
+
This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).
496
+
497
+
If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.
498
+
499
+
If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.
500
+
- session_custom_claims: Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
501
+
502
+
Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.
503
+
- session_token: The `session_token` for the session that you wish to add the trusted auth token authentication factor to.
504
+
- session_jwt: The `session_jwt` for the session that you wish to add the trusted auth token authentication factor to.
0 commit comments