
JanarthK.00342 (Customer) asked a question.
Hello,
I'm developing an application which uses Okta for SSO. I'm using the "passport okta oauth" strategy for the "Passport.js" package on "Node.js" to help authenticate. It does most of the heavy lifting (submitting auth code, client id, secret) and calls a callback with the profile information. For the most part everything already works!
The problem I'm noticing is that when I'm testing on an Okta (test dev org), occasionally the `profile.username` attribute is undefined. I've tried a few things:
- disable/enable okta.users.read.self
- login / logout
What I've noticed is that once I login to the Okta dev org as admin and edit and manually save the user, on their next login the profile.username is correct and not undefined.
I'm not sure what would cause the username to be empty.
The code that processes the username looks like this:
I am not sure what the cause of the undefined username is, and I would like to know what steps I can take to ensure it's always defined.

Callback code the processes the profile:
async (accessToken: any, refreshToken: any, profile: any, done: any) => {
try {
const name = profile.displayName;
const externalId = profile.id;
const email = profile.username;
Hello @JanarthK.00342 (Customer) Thank you for reacting out to our Community!
I have done some research on this matter, but I was unable to find a particular cause for this. One cause of this could be because you are using a Dev environment and might be missing some Features that could fix this issue.
My advice would be to leverage the Okta Developer forums for this type of questions and take advantage of their expertise.
https://devforum.okta.com/
Community members help others by clicking Like or Select as Best on responses. Try it today.