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

Method validate_code_challenge

authlib/oauth2/rfc7636/challenge.py:69–89  ·  view source on GitHub ↗
(self, grant, redirect_uri)

Source from the content-addressed store, hash-verified

67 )
68
69 def validate_code_challenge(self, grant, redirect_uri):
70 request: OAuth2Request = grant.request
71 challenge = request.payload.data.get("code_challenge")
72 method = request.payload.data.get("code_challenge_method")
73 if not challenge and not method:
74 return
75
76 if not challenge:
77 raise InvalidRequestError("Missing 'code_challenge'")
78
79 if len(request.payload.datalist.get("code_challenge", [])) > 1:
80 raise InvalidRequestError("Multiple 'code_challenge' in request.")
81
82 if not CODE_CHALLENGE_PATTERN.match(challenge):
83 raise InvalidRequestError("Invalid 'code_challenge'")
84
85 if method and method not in self.SUPPORTED_CODE_CHALLENGE_METHOD:
86 raise InvalidRequestError("Unsupported 'code_challenge_method'")
87
88 if len(request.payload.datalist.get("code_challenge_method", [])) > 1:
89 raise InvalidRequestError("Multiple 'code_challenge_method' in request.")
90
91 def validate_code_verifier(self, grant, result):
92 request: OAuth2Request = grant.request

Callers

nothing calls this directly

Calls 2

InvalidRequestErrorClass · 0.50
getMethod · 0.45

Tested by

no test coverage detected