CodeChallenge Class
The PKCE code challenge (RFC 7636): what a client sends with its authorization request and an authorization server recomputes from the verifier presented at the token endpoint.
public static class CodeChallengeInheritance System.Object → CodeChallenge
Methods
CodeChallenge.Calculate(string, string) Method
Calculates the code challenge from a code verifier and a method (RFC 7636 section 4.2). PKCE involves transforming the code verifier into a code challenge, which the authorization server verifies when exchanging the authorization code for a token. This method ensures that the correct transformation is applied. It supports both 'plain' and 'S256' methods, with 'S256' being the recommended approach for stronger security.
public static string Calculate(string method, string codeVerifier);Parameters
method System.String
The PKCE challenge method, either 'plain', 'S256' or 'S512'.
codeVerifier System.String
The code verifier submitted by the client during the token request.
Returns
System.String
The transformed code challenge based on the specified method.
CodeChallenge.IsWellFormed(string) Method
Whether value has the syntax both a code verifier and a code challenge share: OAuth 2.1 (draft-ietf-oauth-v2-1-17) section 4.1.1 and RFC 7636 sections 4.1 and 4.2, "code-verifier = 43*128unreserved" and "code-challenge = 43*128unreserved", where "unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"".
public static bool IsWellFormed(string value);Parameters
value System.String
A code verifier or a code challenge as sent.