SPA + .net core backend

Hi all, I’m following this article ASP.NET Core + VueJS
I have a registered Single Page App in React.
I have a registered API, applied to my .net core backend.
I’m correctly logging with the Single Page Application, but when I’m calling the .net core backend, in the log, appear this error:
Bearer was not authenticated. Failure message: IDX10214: Audience validation failed. Audiences: 'https://dataof.eu.auth0.com/api/v2/, https://dataof.eu.auth0.com/userinfo'. Did not match: validationParameters.ValidAudience: 'https://elsoftskeleton.com' or validationParameters.ValidAudiences: 'null'.
The flow of app is this:

  1. The SPA is logged in to Auth0 and in my local storage there is the access token

  2. From the SPA, I’m calling my backend in .net core that has also the implementation of the [Authorize] decorator of Auth0 logics.

  3. The .net core is not authenticating me for the reason that I wrote before.
    Is there a way to solve this problem?
    This is the part of .net core backend

                     string domain = $"https://{Configuration["Auth0:Domain"]}/";
         services.AddAuthentication(options =>
         {
             options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
             options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
    
         }).AddJwtBearer(options =>
         {
             options.Authority = domain;
             options.Audience = Configuration["Auth0:ApiIdentifier"];
         });
    

Thank you

Hi @fabijay88,
I am not a .net developer but I faced this problem in my nodejs application. during JWT verification I was passing the wrong audience and getting this same problem. Currently I am passing audience: 'https://<your.auth0.com>/api/v2/' in jwt verification.

I’ve added details description in my repo GitHub - kdhttps/auth0-angular-node: Auth0 authentication with Angular and NodeJS. Maybe it will help you

1 Like

Yes, this is exactly what I did. But I cannot find any article that explain my solution.
Thank you so much!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.