Auth0 Home Blog Docs

Cannot read property 'username' of undefined



I’m getting "error_description:Cannot read property ‘username’ of undefined"
on Auth0 callback to my server when I use github connection.
I don’t have this problem with other connections.

Also what is interesting is that users was created in Auth0.
Any tips why I might get this problem?


Based on that information and if you consider that custom rules:

  • execute after the initial authentication step so the user profile is already created when they run.
  • are Javascript code.
  • run for every type of connection that the user authenticates with.

It’s highly likely that you have a rule that is throwing an error because the code assumed something that is not true for GH connections, in particular, that there is an object with a username property and for GH that object is undefined.


Thank you!
The problem indeed was in my “rule” - I even forgot I have one.