I use GitHub - okta/okta-auth-js: The official js wrapper around Okta's auth API
I get this error while trying to set tokens using below code
AuthSdkError: The “codeVerifier” (generated and saved by your app) must be passed to /token
My Config
{
issuer: `****.okta.com/oauth2/default`,
clientId: '******',
redirectUri: 'http://localhost:3000/authentication/callback',
scopes: ['openid', 'profile', 'email'],
postLogoutRedirectUri: 'http://localhost:3000/login',
tokenManager: {
autoRenew: false,
},
}
My authenticate method
try {
const transaction = await authClient.signInWithCredentials({
username: 'ajingopi@email.com',
password: '*********',
})
if (transaction?.status === 'SUCCESS') {
authClient.token
.getWithoutPrompt({
responseType: 'code',
pkce: false,
sessionToken: transaction.sessionToken,
scopes: ['openid', 'email', 'profile'],
})
.then(function (res) {
console.log(res)
const tokens = res.tokens
// Do something with tokens, such as
authClient.tokenManager.setTokens(tokens)
})
.catch(function (err) {
console.log(err)
})
}
} catch (error: any) {
console.log(error)
}
It sets a valid okta session but it throws the above error I mentioned initially. I got confirmation from below code.
authClient.session.exists().then(async function (exists) {
if (exists) {
console.log('logged in')
} else {
console.log('not logged in')
}
})
Also once I use authClient.signOut()
once the session is set, it sign out the user from okta session. But not from my udemy sso session.
I would like to know something I am doing wrong. Thanks in advance.