POST to the Keycloak token endpoint and return the access token.
(data: dict[str, str])
| 85 | |
| 86 | |
| 87 | def _token_request(data: dict[str, str]) -> str: |
| 88 | """POST to the Keycloak token endpoint and return the access token.""" |
| 89 | encoded = urllib.parse.urlencode(data).encode() |
| 90 | req = urllib.request.Request(TOKEN_ENDPOINT, data=encoded) |
| 91 | with urllib.request.urlopen(req, timeout=10) as resp: |
| 92 | body = json.loads(resp.read()) |
| 93 | return body["access_token"] |
| 94 | |
| 95 | |
| 96 | def _get_token( |
no test coverage detected