UseOpenIdConnectAuthentication - Unable to unprotect the message.State Error Message
Asked Answered
M

1

6

I am trying to add Google and Azure Active Directory authorities as OpenIdConnect options in my application.

If i add each of them separately, it works fine. But if i add them both i get the following error message:

Unable to unprotect the message.State

These are the OpenIdConnectOptions configuration:

        //Google
        appBuilder.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {                 
            ClientId = ".....apps.googleusercontent.com",
            Authority = $"https://accounts.google.com",
            ClientSecret = "xxxyyyzzzz",
            AuthenticationScheme = "Google",
            DisplayName = "Google",
            AutomaticChallenge = true                                       
        });

        //Azure AD Providers
        var schemeName = "Azure Active Directory";
        var clientId = "1234567890";  
        var tenantId = "0987654321";  

        appBuilder.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {               
            ClientId = clientId,
            ClientSecret = "aaaaabbbbcccc",
            Authority = $"https://login.microsoftonline.com/{tenantId}",
            AuthenticationScheme = "Azure Active Directory",
            DisplayName = "Azure Active Directory",
            AutomaticChallenge = true,                                                
        });
Minelayer answered 3/5, 2017 at 11:33 Comment(0)
P
10

When you have multiple OIDC middleware, you need to set a unique CallbackPath for each of them. Otherwise they are stepping on each other's toes when handling the callback.

Perique answered 3/5, 2017 at 20:5 Comment(4)
yes that was the issue. I thought that just the Authentication Scheme needed to be unique.Minelayer
I don't have multiple OIDC middleware still facing the issue. Any suggestions?Wendling
I don't have mutilple OIDC middlewares too and still facing the errorDeclassify
This answer clarifies and includes an example: #42404677Antlia

© 2022 - 2024 — McMap. All rights reserved.