Skip to content

Commit

Permalink
Merge pull request #13 from makinacorpus/improve_ux
Browse files Browse the repository at this point in the history
Improve developer UX
  • Loading branch information
gbip authored Jun 26, 2024
2 parents 852827b + 4fb382c commit 0331fa9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_pyoidc/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.11
0.0.12
7 changes: 5 additions & 2 deletions django_pyoidc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def import_object(path, def_name):
return getattr(import_module(mod), cls)


def extract_claim_from_tokens(claim: str, tokens: dict) -> Any:
def extract_claim_from_tokens(claim: str, tokens: dict, raise_exception=True) -> Any:
"""Given a dictionnary of tokens claims, extract the given claim.
This function will seek in "info_token_claims", then "id_token_claims"
Expand All @@ -46,7 +46,10 @@ def extract_claim_from_tokens(claim: str, tokens: dict) -> Any:
elif "access_token_claims" and claim in tokens["access_token_claims"]:
value = tokens["access_token_claims"][claim]
else:
raise ClaimNotFoundError(f"{claim} not found in available OIDC tokens.")
if raise_exception:
raise ClaimNotFoundError(f"{claim} not found in available OIDC tokens.")
else:
return None
return value


Expand Down

0 comments on commit 0331fa9

Please sign in to comment.