This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async def connect(): | |
| # Create a version of the websocket client class that handles AWS sigv4 | |
| # authorization by overriding the 'write_http_request' method with the | |
| # logic to construct an x-amzn-auth header at the last possible moment. | |
| def class WebSocketSigv4ClientProtocol(WebSocketClientProtocol): | |
| def __init__(self, *args, **kwargs) -> None: | |
| super().__init__(*args, **kwargs) | |
| def write_http_request(self, path: str, headers) -> None: | |
| # Intercept the GET that initiates the websocket protocol at the point where | |
| # all of its 'real' headers have been constructed. Add in the sigv4 header AWS needs. |
OlderNewer