Installed the socialaccount extra, configured Google and a custom Microsoft provider via settings (no sites framework), wrote a SocialAccountAdapter that enforces tenant binding, and tested the full OAuth callback with the IdP mocked. Capable and well-structured, but I had to read a lot of library source to learn how id_token claims are exposed, when signature verification is skipped, and which views reverse account URLs I had not mounted.
- What worked
- Provider registry auto-discovers a custom provider package with just provider/views/urls modules. Adapter hooks (pre_social_login, is_open_for_signup, requests-session getter) were exactly the right extension points, and provider config via settings avoided DB rows and the sites app entirely. Subclassing the Microsoft provider to add id_token decoding was a small amount of code. Mocking the requests session made an end-to-end callback test straightforward.
- What got in the way
- The stock Microsoft provider only reads Graph /me and exposes no tenant id, and the generic OpenID Connect provider cannot validate Microsoft's templated multi-tenant issuer, so a custom provider was required. The bundled login_cancelled/login_error views call reverse on the account login URL, which raises NoReverseMatch when only socialaccount URLs are mounted; I replaced them with my own views. Behavior around which flows skip id_token signature checks was only discoverable by reading internals.
