@@ -33,15 +33,24 @@ def integration_latency(self) -> Optional[int]:
33
33
"""The authorizer latency in ms."""
34
34
return self .get ("integrationLatency" )
35
35
36
- def get_context (self ) -> Optional [Dict [str , Any ]]:
37
- """Retrieve the authorization context details for Lambda.
36
+ def get_context (self ) -> Dict [str , Any ]:
37
+ """Retrieve the authorization context details injected by a Lambda Authorizer.
38
+
39
+ Example
40
+ --------
41
+
42
+ ```python
43
+ ctx: dict = ...request_context.authorizer.get_context()
44
+
45
+ tenant_id = ctx.get("tenant_id")
46
+ ```
38
47
39
48
Returns:
40
49
--------
41
- Optional[ Dict[str, Any] ]
42
- A dictionary containing Lambda authorization context details, or None if the information is not available .
50
+ Dict[str, Any]
51
+ A dictionary containing Lambda authorization context details.
43
52
"""
44
- return self
53
+ return self . _data
45
54
46
55
47
56
class APIGatewayEventRequestContext (BaseRequestContext ):
@@ -195,14 +204,23 @@ def get_lambda(self) -> Optional[Dict[str, Any]]:
195
204
return self .get ("lambda" )
196
205
197
206
def get_context (self ) -> Optional [Dict [str , Any ]]:
198
- """Retrieve the authorization context details for Lambda.
207
+ """Retrieve the authorization context details injected by a Lambda Authorizer.
208
+
209
+ Example
210
+ --------
211
+
212
+ ```python
213
+ ctx: dict = ...request_context.authorizer.get_context()
214
+
215
+ tenant_id = ctx.get("tenant_id")
216
+ ```
199
217
200
218
Returns:
201
219
--------
202
- Optional[ Dict[str, Any] ]
203
- A dictionary containing Lambda authorization context details, or None if the information is not available .
220
+ Dict[str, Any]
221
+ A dictionary containing Lambda authorization context details.
204
222
"""
205
- return self .get ("lambda" )
223
+ return self .get ("lambda" , {} )
206
224
207
225
@property
208
226
def iam (self ) -> Optional [RequestContextV2AuthorizerIam ]:
0 commit comments