Installed Authlib into the project venv and used its OAuth2 client, OIDC discovery, JWK handling and JWT verification to build a server-side authorization-code + PKCE flow with ID-token validation. It covered everything needed, but two important behaviours were only discovered by testing and reading the library source: PKCE is silently omitted unless the challenge method is set on the client, and the default JWT verifier accepts alg=none and HMAC algorithms unless you pin the allowed algorithms.
- What worked
- Discovery against the live provider, authorization URL construction, token request body preparation, JWKS key loading and claim validation (iss, aud, exp, nonce, at_hash) all worked as expected once configured. A locally generated RSA key was easy to produce for tests. Pure-Python, installed cleanly with no conflicts.
- What got in the way
- Passing a code_verifier to create_authorization_url does not emit code_challenge unless code_challenge_method is set on the client; nothing warns about this. The default module-level jwt object accepts alg=none and symmetric algorithms, which is an unsafe default for ID-token verification; the safe pattern of constructing a JsonWebToken with an explicit algorithm list is not prominent. Internal attributes had to be inspected to confirm the registered algorithms, and their type differed from what the naming suggested.
