MCPcopy Create free account
hub / github.com/authlib/authlib / encode_id_token

Method encode_id_token

authlib/oidc/core/grants/code.py:62–87  ·  view source on GitHub ↗
(self, token, request: OAuth2Request)

Source from the content-addressed store, hash-verified

60 raise NotImplementedError()
61
62 def encode_id_token(self, token, request: OAuth2Request):
63 alg = self.get_client_algorithm(request.client)
64 header = self.get_encode_header(request.client)
65
66 claims = self.get_compatible_claims(request)
67 if request.authorization_code:
68 claims.update(
69 self.get_authorization_code_claims(request.authorization_code)
70 )
71
72 access_token = token.get("access_token")
73 if access_token:
74 at_hash = create_half_hash(access_token, alg)
75 if at_hash is not None:
76 claims["at_hash"] = at_hash.decode("utf-8")
77
78 user_info = self.generate_user_info(request.user, token["scope"])
79 claims.update(user_info)
80
81 if alg == "none":
82 private_key = None
83 else:
84 key = self.resolve_client_private_key(request.client)
85 private_key = import_any_key(key)
86
87 return jwt.encode(header, claims, private_key, [alg])
88
89 def process_token(self, grant, response):
90 _, token, _ = response

Callers 1

process_tokenMethod · 0.95

Calls 11

generate_user_infoMethod · 0.95
import_any_keyFunction · 0.90
create_half_hashFunction · 0.85
get_client_algorithmMethod · 0.80
get_encode_headerMethod · 0.80
get_compatible_claimsMethod · 0.80
decodeMethod · 0.80
encodeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected