feat: add get_jwks_url helper to UserManagement#644
Conversation
v6 exposed `user_management.get_jwks_url()` as a small helper for constructing the JWKS URL — useful when integrating with JWT libraries (e.g. `PyJWKClient`) that fetch and cache the JWKS themselves given a URL. The v7 generator emits `get_jwks()` which fetches the JWKS document, but no equivalent URL builder, so users had to hand-construct the URL. Adds `get_jwks_url(client_id=None)` to both `UserManagement` and `AsyncUserManagement` inside the existing `@oagen-ignore` fences. The parameter is optional and falls back to the client's configured `client_id`, matching v6 ergonomics. URL construction mirrors the internal `session.py` pattern exactly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Greptile SummaryAdds a Confidence Score: 5/5Safe to merge; the change is small, correct, and follows established codebase patterns. Implementation mirrors the existing URL-construction pattern from session.py and the client_id fallback pattern from sso/_resource.py exactly. The only gap is a missing ConfigurationError test for the async class (P2), which does not affect correctness. No files require special attention. Important Files Changed
|
| class TestAsyncGetJwksUrl: | ||
| async def test_uses_configured_client_id(self, async_workos): | ||
| url = async_workos.user_management.get_jwks_url() | ||
| assert url == "https://api.workos.com/sso/jwks/client_test" | ||
|
|
||
| async def test_explicit_client_id_overrides_default(self, async_workos): | ||
| url = async_workos.user_management.get_jwks_url("client_other") | ||
| assert url == "https://api.workos.com/sso/jwks/client_other" |
There was a problem hiding this comment.
get_jwks_url helper to UserManagement
Summary
Adds
user_management.get_jwks_url(client_id=None)to both sync and async clients — a small helper that constructs the JWKS URL for a given client.Why
v6 exposed
user_management.get_jwks_url(), which customers used to integrate with JWT libraries that take a URL and handle fetching/caching themselves (e.g. PyJWT'sPyJWKClient(url)). v7's generatedget_jwks(client_id)returns the JWKS document, not the URL — so customers integrating with URL-based JWT libraries have been hand-constructing the URL withf"{client.base_url}sso/jwks/{client_id}", duplicating whatsession.pydoes internally.Implementation
get_jwks_urltoUserManagementandAsyncUserManagementinside the existing@oagen-ignore-start/@oagen-ignore-endfences insrc/workos/user_management/_resource.py. Verified the methods survivenpm run sdk:generate -- --lang python.Optional[str]with fallback to the client's configuredclient_idvia_require_client_id()— matches v6 ergonomics where the method took no arguments.session.py:195/session.py:373exactly.Test plan
uv run pytest tests/test_inline_helpers.py -k "JwksUrl"— 5 new tests pass (default lookup, explicit override,ConfigurationErrorwhen no client_id; sync + async)uv run pytest tests/test_inline_helpers.py tests/test_user_management.py tests/test_session.py— 184 tests passuv run ruff format --checkanduv run ruff check— cleanuv run pyright— 0 errorsget_jwks_urlsurvives a fullnpm run sdk:generaterun🤖 Generated with Claude Code