I am facing a issue where upon using method signInWithCredentials() I am not getting the access token or Id token and unable to call getUserInfo()
async handleSignInResponse(transaction: AuthnTransaction) {
if (transaction.status !== ‘SUCCESS’) {
throw new Error(We cannot handle the ${transaction.status} status
);
}
this._authClient.tokenManager.get(‘accessToken’)
.then((value:any) => {
console.info("Access token: " + value.accessToken);
})
this._authSub$.next(true);
await this._authClient.session.setCookieAndRedirect(transaction.sessionToken);
}
public login(username: string, password: string): Observable {
return from(this._authClient.signInWithCredentials({username, password})).pipe(
map((t) => {
console.log('t → ', t);
// this.getUser();
this.handleSignInResponse(t);
})
);
}
Did you check to see if the request to Okta succeeded? If you log the transaction
, what does it look like? Did it result in a “SUCCESS”, or does the user maybe need to verify an additional factor in order to complete primary authentication?
If you’re not familiar with the /authn transaction states, you can find a diagram of the flow for the /authn endpoint (used by signInWithCredentials) here: Authentication | Okta Developer
Hello,
Thanks for the step by step tutorial. Works like a charm!
Best Regard
Ford Benefits