OpenIdConnectAuthenticationHandler: message.State is null or empty.

Shripad Godse 25 Reputation points
2023-12-20T11:28:37.81+00:00

I have a multi-tenant application in Microsoft Entra ID, which I use for Single Sign-On in my .NET 6 (API) and Angular 7 application as shown in the attached screenshots. When I click on my application in the My App section of Office apps, I get the following exception message:

System.Exception: An error was encountered while handling the remote login. ---> System.Exception: OpenIdConnectAuthenticationHandler: message.State is null or empty.

I have already raised my concern here, but haven't had any luck yet. I have attached screenshots of my implementation and controller for reference.
Implementation:

Screenshot 2023-12-13 185146

Controller:

User's image

My App from microsot app section:

User's image

Developer technologies ASP.NET ASP.NET Core
Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Crystal Lee Morgan 380 Reputation points
    2023-12-20T17:35:00.4+00:00

    @Shripad Godse The error message “OpenIdConnectAuthenticationHandler: message.State is null or empty” is usually caused by the fact that you are not using the OpenID Connect provider configuration discovery feature offered by the OIDC middleware, that allows it to retrieve the cryptographic keys used to sign identity tokens <sup>1</sup>. If your provider supports this feature, remove the entire Configuration node and set Authority instead <sup>2</sup>.

    You can try the following steps to resolve the issue:

    1. Make sure that you have configured the OpenID Connect provider correctly in your application.
    2. Check if your provider supports the OpenID Connect provider configuration discovery feature.
    3. Remove the entire Configuration node and set Authority instead.
    4. Set the AuthenticationProperties.State parameter to a non-null value before calling the Challenge method.

    If the above steps do not resolve the issue, you can try contacting Azure support for further assistance <sup>3</sup>.

    I hope this helps! Let me know if you have any other questions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.