Hi all,
I’m new to Okta, javascript and OIDC so please excuse the novice question
I’m trying to get a simple Authorization Code Flow working using the okta-auth-js sdk.
I have my application configured in Okta which seems to be working fine, it’s the use of the sdk that’s confusing me. My signInWithCredentials call is returning a status of SUCCESS but when I call authClient.isAuthenticated() i’m seeing a return of false.
All i’m really trying to do at this stage is retrieve the claims, scopes and the access token.
Is there something else I need to do between the two calls?
Thanks,
W
const authClient = new OktaAuth({
issuer: oidcConfig.get(“Issuer”),
clientId: oidcConfig.get(“ClientID”),
redirectUri: redirectURI
});authClient.signInWithCredentials({username: username, password: password})
.then(tx => {console.info("signInWithCredentials called. Status returned: " + tx.status ); if (tx.status === 'SUCCESS') { console.info('Authorisation successful'); console.info("Session token is: " + tx.sessionToken); authClient.isAuthenticated() .then(value => { if (!value) { console.info('Not authenticated'); } else { console.info("Client is authenticated, retrieving access token..."); authClient.tokenManager.get('accessToken') .then(value => { console.info("Access token: " + value.accessToken); }) } }) } else { console.info("signInWithCredentials not successful. Status is: " + tx.status); throw new Error(`We cannot handle the ${tx.status} status.`) }
})
.catch(e => {
console.info("Failed login, signInWithCredentials returned error: " + e);
throw new Error ('Error captured whilst logging in: ’ + e);
})