Skip to content

Scopes in custom UserInfo claims #952

@johanneskvamme

Description

@johanneskvamme

Great seeing OpenID Connect integrated into django-oauth-toolkit! 🎉
I am currently working on porting our systems from django-oidc-provider as many others probably are as well.

To keep the end-user experience as unchanged as possible, I would like both the /userinfo-endpoint and the ID-token to contain all approved scope-claims.
As such, I am following the instructions from the customizing-the-oidc-responses section.

First question:

The code snippet below does not send any arguments to super().get_userinfo_claims(), while my code complains that it wants the request, i.e super().get_userinfo_claims(request). Is it just missing in the docs or have I configured it wrongly?

class CustomOAuth2Validator(OAuth2Validator):

    def get_userinfo_claims(self, request):
        claims = super().get_userinfo_claims()
        claims["color_scheme"] = get_color_scheme(request.user)
        return claims

Second question:

When calling super().get_userinfo_claims(), my understanding is that it invokes get_additional_claims under the hood.
However, then passing the request at this point, no scope other than "openid" is present in the scope list. When generating the id_token, all scopes are present as they should, so I add different claims based on them. However, I seem to be unable to get the same claims for the /userinfo-endpoint. Am I doing something wrong, or is this a bug?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions