Get user email/token for failed OIDC login

Hello,

I am working on a feature that suggests user registration when a user exists in AADUser (via OIDC authentication) but is not present in the Person table. During this process, I encountered the following error:

“You are not authorized to use this database.”

Upon receiving this error, I have implemented logic to display a registration form. I would like to request guidance on one of the following:

  1. Obtaining a token or claim that includes the user’s email address so it can be used to prepopulate the registration form, or

  2. Customizing the error handling process to include user information (such as email) for a smoother registration experience.

Could you please advise if there is an approach or recommended best practice to achieve this?

Thank you for your support.