You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] "The issuer '(null)' is invalid" error when I request my API with bearer token #1167
I think that this is a Microsoft.Identity.Web issue (in the issuer validation)
###Analysis
Looking at the OIDC metadata for https://login.chinacloudapi.cn, I don't see the aliases property, whereas it's currently required by the standard issuer validator:
The https://login.chinacloudapi.cn/ alias is no longer the preffered network alias, but it's still an alias. However, sts.chinacloud.cn is not an alias. Does this mean this is an external problem?
Yang, ORI (@Gtyrande) can you try with https://login.partner.microsoftonline.cn/ instead?
I tried sts.chinadloudapi.cn and login.partner.microsoftonline.cn at both frontend acquire token process and backend validate token process, result is same as I posted.
I never use sts.chinacloud.cn before in my code, but in access token the issuer is always sts.chinacloud.cn. Maybe there is something wrong with msal.js 2.0?
I think that this is a Microsoft.Identity.Web issue (in the issuer validation)
###Analysis
Looking at the OIDC metadata for https://login.chinacloudapi.cn, I don't see the aliases property, whereas it's currently required by the standard issuer validator:
I tried https://sts.chinacloudapi.cn/{tenantid}/ but nothing changed.
I'm just to write a demo for our vendor to explain the process of Azure AD. Their tech-stack is Maven/Java, so it's not an urgent problem if msal.java is good.
I will tell them to try msal.java. If it's not work, they can customize a validator in middleware.
Yang, ORI (@Gtyrande) - this seems to be an actual server bug. The token is marked as having been issued by sts.chinacloud.cn\<tenant>, however this is not cloud alias is not known. AAD publishes the aliases here and the token validator has no way of knowing that https://login.chinacloudapi.cn/ and https://sts.chinacloud.cn/ are the same.
As a possible workaround, you can try to set the authority as sts.chinacloud.cn, but I would advise against it. The course of action is to open an incident (ICM, as I believe you are internal) to the server team (ESTS > ESTS). You'll need a correlation id for when you get a token. Ping us if you need help.
Did you use Identity.Web 1.13.0 that we just released?
Do you need to have the "Authority" property in the web API appsettings.json ? It should not be necessary (it will be computed from the Instance and Tenant ID
What is the token version required by your API? (from the app registration: acceptedTokenVersion)
Thanks Yang, ORI (@Gtyrande): yes. this is the right property. This means the web API is a v1.0 API.
Looking at the open id configuration: https://login.partner.microsoftonline.cn/common/.well-known/openid-configuration, the issuer is ending https://sts.chinacloudapi.cn/{tenantid}/.
Is the issuer in your access token the same?
Since version 1.13, I get the above error (""The issuer '(null)' is invalid") when validating an access token in my API (ASP.NET 5.0). With version 1.12 all works fine.
Token is obtained using msal.js for angular v 2.0.0 (it sends a request to https://login.microsoftonline.com/organizations/oauth2/v2.0/token). Again, with Microsoft.Identity.Web 1.12.0, the token is validated just fine; in 1.13.0 I get an error about invalid issuer. As you can see in the below screenshot, the 'iss' claim is not null though, it is https://sts.windows.net/<my tenantId>/
publicvoidConfigure(IApplicationBuilderapp,IWebHostEnvironmentenv){if(env.IsDevelopment()){app.UseDeveloperExceptionPage();}app.UseSerilogRequestLogging();app.UseHttpsRedirection();app.UseRouting();// The UseCors call must be placed between UseRouting and UseAuthentication.// See https://docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-5.0#middleware-order.app.UseCors(CorsPolicyName);app.UseAuthentication();app.UseAuthorization();// Custom middleware must be placed between UseAuthorization and UseEndpoints.app.UseRoleBasedAccessControl();app.UseJsonApi();app.UseEndpoints(endpoints =>{// Require callers to be authenticated and have the minimum scope claim.endpoints.MapControllers().RequireAuthorization("MinimumScope");});}
With app.UseRoleBasedAccessControl(), I am inserting my own custom middleware into the pipeline. With 1.14.0, the requests do not reach my custom middleware.
I've successfully decoded and validated the tokens using both jwt.ms and jwt.io:
As you see, the iss claim is not null. I am wondering why I am getting "ver": "1.0" tokens and do not know how to change that or whether that is an issue.
Activity
jmprieur commentedon Apr 29, 2021
I think that this is a Microsoft.Identity.Web issue (in the issuer validation)
###Analysis
Looking at the OIDC metadata for https://login.chinacloudapi.cn, I don't see the aliases property, whereas it's currently required by the standard issuer validator:
microsoft-identity-web/src/Microsoft.Identity.Web/Resource/MicrosoftIdentityIssuerValidatorFactory.cs
Line 76 in b93c676
Metadata:
https://login.chinacloudapi.cn/common/.well-known/openid-configuration
Possible fix:
Union m => m.Aliases with
m.Issuerwhich is defined in the case of https://login.chinacloudapi.cn, and before doing the call to Distinct.Possible work around
I have not tested. maybe have ValidIssuer set to https://sts.chinacloudapi.cn/{tenantid}/ in the appsettings.json?
Yang, ORI (@Gtyrande) : how urgent is this for you?
bgavrilMS commentedon Apr 29, 2021
Yang, ORI (@Gtyrande) can you try with
https://login.partner.microsoftonline.cn/instead?bgavrilMS commentedon Apr 29, 2021
Jean-Marc Prieur (@jmprieur) - the aliases are not in the OIDC metadata, they are in the instance metadata document https://login.microsoftonline.com/common/discovery/instance?authorization_endpoint=https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize&api-version=1.1
The
https://login.chinacloudapi.cn/alias is no longer the preffered network alias, but it's still an alias. However,sts.chinacloud.cnis not an alias. Does this mean this is an external problem?Gtyrande commentedon Apr 29, 2021
I tried
sts.chinadloudapi.cnandlogin.partner.microsoftonline.cnat both frontend acquire token process and backend validate token process, result is same as I posted.I never use
sts.chinacloud.cnbefore in my code, but in access token the issuer is alwayssts.chinacloud.cn. Maybe there is something wrong with msal.js 2.0?Gtyrande commentedon Apr 29, 2021
I tried
https://sts.chinacloudapi.cn/{tenantid}/but nothing changed.I'm just to write a demo for our vendor to explain the process of Azure AD. Their tech-stack is Maven/Java, so it's not an urgent problem if msal.java is good.
I will tell them to try msal.java. If it's not work, they can customize a validator in middleware.
bgavrilMS commentedon Apr 29, 2021
Yang, ORI (@Gtyrande) - this seems to be an actual server bug. The token is marked as having been issued by
sts.chinacloud.cn\<tenant>, however this is not cloud alias is not known. AAD publishes the aliases here and the token validator has no way of knowing thathttps://login.chinacloudapi.cn/andhttps://sts.chinacloud.cn/are the same.As a possible workaround, you can try to set the authority as
sts.chinacloud.cn, but I would advise against it. The course of action is to open an incident (ICM, as I believe you are internal) to the server team (ESTS > ESTS). You'll need a correlation id for when you get a token. Ping us if you need help.9 remaining items
jennyf19 commentedon Jun 4, 2021
Yang, ORI (@Gtyrande) the fix is in this branch if you want to try it. Someone from US gov cloud has tried it out with success. thank you.
jennyf19 commentedon Jun 11, 2021
Fixed in 1.13 release.
Gtyrande commentedon Jun 11, 2021
jennyf19 Sorry for late reply and thank you for new release. As I tested this error never shows again.
But I got a 404 response and I can’t tell where the problem is. Could you help me about this?

My Vue App code:
My .NET API code:
jmprieur commentedon Jun 11, 2021
Yang, ORI (@Gtyrande):
Gtyrande commentedon Jun 12, 2021
Jean-Marc Prieur (@jmprieur)
jmprieur commentedon Jun 12, 2021
Thanks Yang, ORI (@Gtyrande): yes. this is the right property. This means the web API is a v1.0 API.
Looking at the open id configuration:
https://login.partner.microsoftonline.cn/common/.well-known/openid-configuration, the issuer is endinghttps://sts.chinacloudapi.cn/{tenantid}/.Is the issuer in your access token the same?
jlpstolwijk commentedon Jun 14, 2021
Since version 1.13, I get the above error (""The issuer '(null)' is invalid") when validating an access token in my API (ASP.NET 5.0). With version 1.12 all works fine.
Token is obtained using msal.js for angular v 2.0.0 (it sends a request to https://login.microsoftonline.com/organizations/oauth2/v2.0/token). Again, with Microsoft.Identity.Web 1.12.0, the token is validated just fine; in 1.13.0 I get an error about invalid issuer. As you can see in the below screenshot, the 'iss' claim is not null though, it is
https://sts.windows.net/<my tenantId>/appSettings.json:
startup.cs code (completely boilerplate):
services.AddAuthentication().AddMicrosoftIdentityWebApi(_config)Example of decoded token in jwt.ms:

ThomasBarnekow commentedon Jul 12, 2021
I have the same issue as Yang, ORI (@Gtyrande) and Joris (@jlpstolwijk) with 1.14.0, which I just installed. With 1.12.0, everything works as expected.
On the client side, I am using both Postman v8.7.0 and MSAL for Angular:
On the server side, I am using ASP.NET Core 5.0 with the following configuration:
appsettings.json
Startup.ConfigureServices(IServiceCollection services)
Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env)
With
app.UseRoleBasedAccessControl(), I am inserting my own custom middleware into the pipeline. With 1.14.0, the requests do not reach my custom middleware.I've successfully decoded and validated the tokens using both jwt.ms and jwt.io:
As you see, the
issclaim is not null. I am wondering why I am getting"ver": "1.0"tokens and do not know how to change that or whether that is an issue.ohadschn commentedon Sep 18, 2021
Adding some keywords which would have saved me hours of research and debugging:
shuichen17 commentedon Jun 10, 2023
I use
Microsoft.Identity.Web1.25.3and set"accessTokenAcceptedVersion": 2Here is my code
It works properly. My app is multitenant.