function encodeChallenge_(method, codeVerifier) {
  method = method.toLowerCase();

  if (method === 'plain') {
    return codeVerifier;
  }

  if (method === 's256') {
    const hashedValue = Utilities.computeDigest(
        Utilities.DigestAlgorithm.SHA_256,
        codeVerifier,
        Utilities.Charset.US_ASCII);
    return encodeUrlSafeBase64NoPadding_(hashedValue);
  }

  throw new Error('Unsupported challenge method: ' + method);
}
Encodes a challenge string for PKCE.

@param {string} method Encoding method (S256 or plain)
@param {string} codeVerifier String to encode
@return {string} BASE64(SHA256(ASCII(codeVerifier)))