Код: Выделить всё
error=invalid_request&error_description=PKCE+code+challenge+contains+illegal+characters.
< /code>
Есть статья, описывающая ее, но это не очень полезно. Похоже, что проблема заключается в том, что мой code_challenge
Code_challenge является хэш SHA256 BASE64, кодированного 64
Код: Выделить всё
import * as node_crypto from 'node:crypto';
class OktaAccessManager {
constructor() {
// todo: remember and periodically purge
this.challenges = new Map();
}
createChallenge() {
const randomString = "ddd";
const hash = node_crypto.createHash('sha256')
.update(randomString)
.digest('base64');
const challenge = {
hash: hash,
method: 'sha256',
secretString: randomString
};
return challenge;
}
< /code>
Тогда я просто генерирую простой перенаправление на моем Express Server: < /p>
const redirectUrl = `https://${SERVER_HOSTNAME}/auth/okta-callback`;
const challenge = oktaManager.createChallenge();
const params = new URLSearchParams({
client_id: "XXXXXXXXXXXXXXXXX",
state: "state-AAAAAAA-AAAA-AAAA-25cf-386e3d8967e9",
redirect_uri: redirectUrl,
response_type: "code",
scope: "email openid",
code_challenge: challenge.hash,
code_challenge_method: "S256",
});
const fullURL = new URL(`https://${OKTA_SERVER}/oauth2/v1/authorize`);
fullURL.search = params.toString();
res.header("Cache-Control", "no-store");
res.header("Pragma", "no-cache");
res.header("X-Content-Type-Options", "nosniff");
res.header("X-Frame-Options", "DENY");
res.header("X-XSS-Protection", "1; mode=block");
res.redirect(301, fullURL.toString());
Подробнее здесь: https://stackoverflow.com/questions/796 ... 4-includes