graphql-dotnet / graphql-dotnet/authorization

UNAUTHENTICATED error code

Open
#121 3 comments 0 reactions 1 assignee Claimed by @sungam3r View on GitHub
question
Dominant language
C#
Stars
160
Forks
38
PR merge metrics
No merged PRs in 30d

Description

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();
services.TryAddSingleton();
services.AddTransient();
services.AddTransient((c) =>{
var authSettings = new AuthorizationSettings();
authSettings.AddPolicy("authenticated",p=>p.RequireClaim(ClaimTypes.Name));
return authSettings;
);
```

```
app.UseAuthentication();
app.UseAuthorization();
app.UseGraphQL("/api");
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.