Skip to content

UNAUTHENTICATED error code #121

@EbrahimMajdey

Description

@EbrahimMajdey

I just need to know how to get the error code UNAUTHENTICATED because when I use .AuthorizeWith I am getting a VALIDATION_ERROR.

here is a bit of startup.cs

        services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer();
            services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            services.TryAddSingleton<IAuthorizationEvaluator, AuthorizationEvaluator>();
            services.AddTransient<IValidationRule, AuthorizationValidationRule>();
            services.AddTransient((c) =>{
                               var authSettings = new AuthorizationSettings();
                           authSettings.AddPolicy("authenticated",p=>p.RequireClaim(ClaimTypes.Name));
                          return authSettings;
            );
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseGraphQL<MySchema>("/api");

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions