OpenIdConnect error - Tenant identifiers may not b

2019-05-04 10:20发布

问题:

I'm attempting to use the OWIN Open ID Connect middleware to outsource authentication for my ASP.NET application to Azure Active Directory. The application successfully redirects to the Azure AD sign-in page upon accessing a page that requires authorisation. However upon signing in to Azure AD I'm encountering the following error:

AADSTS90002: Requested tenant identifier '00000000-0000-0000-0000-000000000000' is not valid. Tenant identifiers may not be an empty GUID.

Here is the call to UseOpenIdConnectAuthentication. The tenant which is included in the Authority URL is f82d0e29-6018-43c6-b806-1f46a009ff4a. So why does Azure AD think I am passing in an empty GUID for the tenant?

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
            {
                AuthenticationType = "AzureAd",
                Caption = "Office 365",
                Scope = "openid email profile",
                ClientId = "e34401b2-6a9f-4547-9229-f0d93a33b1a1",
                Authority = "https://login.windows.net/f82d0e29-6018-43c6-b806-1f46a009ff4a/",
                PostLogoutRedirectUri = "http://localhost:44333",
                RedirectUri = "http://localhost:44333",
                AuthenticationMode = AuthenticationMode.Passive,
                SignInAsAuthenticationType = signInAsType
            });

回答1:

There may be a bug in AAD right now. Another thread also started around the same time as this one: Empty GUID error when using Azure AD consent flow - According to one comment the AAD team is aware and looking into it.

UPDATE:

See my version of this question for the full diagnosis and solution:

Azure Active Directory passing empty GUID for tenantId with default template