Skip to content

Commit a7d824e

Browse files
Add docstrings
1 parent cb16477 commit a7d824e

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

stytch/consumer/api/idp.py

+48
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ def introspect_idp_access_token(
3232
client_secret: Optional[str] = None,
3333
token_type_hint: str = "access_token",
3434
) -> Optional[AccessTokenJWTClaims]:
35+
"""Introspects a token JWT from an authorization code response.
36+
Access tokens and refresh tokens are JWTs signed with the project's JWKs.
37+
Access tokens contain a standard set of claims as well as any custom claims generated from templates.
38+
39+
Fields:
40+
- access_token: The access token (or refresh token) to introspect.
41+
- client_id: The ID of the client.
42+
- client_secret: The secret of the client.
43+
- token_type_hint: A hint on what the token contains. Valid fields are 'access_token' and 'refresh_token'.
44+
"""
3545
return self.introspect_idp_access_token_local(
3646
access_token, client_id
3747
) or self.introspect_idp_access_token_network(
@@ -45,6 +55,16 @@ async def introspect_idp_access_token_async(
4555
client_secret: Optional[str] = None,
4656
token_type_hint: str = "access_token",
4757
) -> Optional[AccessTokenJWTClaims]:
58+
"""Introspects a token JWT from an authorization code response.
59+
Access tokens and refresh tokens are JWTs signed with the project's JWKs.
60+
Access tokens contain a standard set of claims as well as any custom claims generated from templates.
61+
62+
Fields:
63+
- access_token: The access token (or refresh token) to introspect.
64+
- client_id: The ID of the client.
65+
- client_secret: The secret of the client.
66+
- token_type_hint: A hint on what the token contains. Valid fields are 'access_token' and 'refresh_token'.
67+
"""
4868
local_introspection_response = self.introspect_idp_access_token_local(access_token, client_id)
4969
if local_introspection_response is not None:
5070
return local_introspection_response
@@ -59,6 +79,16 @@ def introspect_idp_access_token_network(
5979
client_secret: Optional[str] = None,
6080
token_type_hint: str = "access_token",
6181
) -> Optional[AccessTokenJWTClaims]:
82+
"""Introspects a token JWT from an authorization code response.
83+
Access tokens and refresh tokens are JWTs signed with the project's JWKs.
84+
Access tokens contain a standard set of claims as well as any custom claims generated from templates.
85+
86+
Fields:
87+
- access_token: The access token (or refresh token) to introspect.
88+
- client_id: The ID of the client.
89+
- client_secret: The secret of the client.
90+
- token_type_hint: A hint on what the token contains. Valid fields are 'access_token' and 'refresh_token'.
91+
"""
6292
headers: Dict[str, str] = {"Content-Type": "application/x-www-form-urlencoded"}
6393
data: Dict[str, Any] = {
6494
"token": access_token,
@@ -95,6 +125,16 @@ async def introspect_idp_access_token_network_async(
95125
client_secret: Optional[str] = None,
96126
token_type_hint: str = "access_token",
97127
) -> Optional[AccessTokenJWTClaims]:
128+
"""Introspects a token JWT from an authorization code response.
129+
Access tokens and refresh tokens are JWTs signed with the project's JWKs.
130+
Access tokens contain a standard set of claims as well as any custom claims generated from templates.
131+
132+
Fields:
133+
- access_token: The access token (or refresh token) to introspect.
134+
- client_id: The ID of the client.
135+
- client_secret: The secret of the client.
136+
- token_type_hint: A hint on what the token contains. Valid fields are 'access_token' and 'refresh_token'.
137+
"""
98138
headers: Dict[str, str] = {"Content-Type": "application/x-www-form-urlencoded"}
99139
data: Dict[str, Any] = {
100140
"token": access_token,
@@ -129,6 +169,14 @@ def introspect_idp_access_token_local(
129169
access_token: str,
130170
client_id: str,
131171
) -> Optional[AccessTokenJWTClaims]:
172+
"""Introspects a token JWT from an authorization code response.
173+
Access tokens and refresh tokens are JWTs signed with the project's JWKs.
174+
Access tokens contain a standard set of claims as well as any custom claims generated from templates.
175+
176+
Fields:
177+
- access_token: The access token (or refresh token) to introspect.
178+
- client_id: The ID of the client.
179+
"""
132180
_scope_claim = "scope"
133181
generic_claims = jwt_helpers.authenticate_jwt_local(
134182
project_id=self.project_id,

stytch/consumer/models/idp.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@
66

77

88
class AccessTokenJWTResponse(ResponseBase):
9-
"""Response type for `Sessions.introspect_idp_access_token`.
9+
"""Response type for `IDP.introspect_idp_access_token`.
1010
Fields:
1111
- active: Whether or not this token is active.
1212
- sub: Subject of this JWT.
1313
- scope: A space-delimited string of scopes this JWT is granted.
14+
- aud: Audience of this JWT. Usually the user or member ID, and any custom audience, if present.
15+
- exp: Expiration of this access token, in Unix time.
16+
- iat: The time this access token was issued.
17+
- iss: The issuer of this access token.
18+
- nbf: The time before which the JWT must not be accepted for processing.
1419
""" # noqa
1520

1621
active: bool
@@ -24,11 +29,16 @@ class AccessTokenJWTResponse(ResponseBase):
2429

2530

2631
class AccessTokenJWTClaims(pydantic.BaseModel):
27-
"""Response type for `Sessions.introspect_idp_access_token`.
32+
"""Response type for `IDP.introspect_idp_access_token`.
2833
Fields:
2934
- subject: The subject (either user_id or member_id) that the JWT is intended for.
3035
- scope: A space-delimited string of scopes this JWT is granted.
3136
- custom_claims: A dict of custom claims of the JWT.
37+
- audience: Audience of this JWT. Usually the user or member ID, and any custom audience, if present.
38+
- expires_at: Expiration of this access token, in Unix time.
39+
- issued_at: The time this access token was issued.
40+
- issuer: The issuer of this access token.
41+
- not_before: The time before which the JWT must not be accepted for processing.
3242
""" # noqa
3343

3444
subject: str

0 commit comments

Comments
 (0)