Cannot import name ScopeClaims circular dependency
JordiNeil opened this issue · 1 comments
JordiNeil commented
I created a CustomScopeClaims just as in documentation but the test_claims test fails with error
ImportError: cannot import name 'ScopeClaims' from partially initialized module 'oidc_provider.lib.claims' (most likely due to a circular import)
And make sense because settings.py imports ScopeClaims
from oidc_provider.lib.claims import ScopeClaims
and ScopeClaims imports settings
from oidc_provider import settings
In ScopeClaims class, settings is just being used to get the OIDC_USERINFO constant.
settings.get('OIDC_USERINFO', import_str=True)(claims, self.user)
Can anyone help me? Which is the best way to solve this.
JordiNeil commented
I think I solved it, I just had to move the CustomScopeClaims class to the oidc_provider.lib.claims file and update the constant in the Django settings file
OIDC_EXTRA_SCOPE_CLAIMS = 'yourproject.oidc_provider_settings.CustomScopeClaims'
to
OIDC_EXTRA_SCOPE_CLAIMS = 'yourproject.oidc_provider.lib.claims.CustomScopeClaims'
I this should be in the doc @juanifioren If you create customScopes in the location the Documentation says, the Tests will fail due to circular dependency error.