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
Copy file name to clipboardExpand all lines: support/entra/entra-id/app-integration/401-unauthorized-aspnet-core-web-api.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,12 +41,12 @@ public class MyController : ControllerBase
41
41
42
42
## Cause
43
43
44
-
the API might return 401 Unauthorized responses in the following scenarios:
44
+
The API might return 401 Unauthorized responses in the following scenarios:
45
45
46
-
- The request does not include a valid Authorization: Bearer token header.
46
+
- The request doesn't include a valid Authorization: Bearer token header.
47
47
- Token is expired or incorrect.
48
48
- The token being issued for a different resource.
49
-
- Token claims not meeting the application's application's token validation criteria as defined in the [JwtBearerOptions.TokenValidationParameters](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbeareroptions.tokenvalidationparameters) class.
49
+
- Token claims not meeting the application's token validation criteria as defined in the [JwtBearerOptions.TokenValidationParameters](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbeareroptions.tokenvalidationparameters) class.
50
50
51
51
## Solution
52
52
@@ -55,7 +55,7 @@ To debug and resolve 401 Unauthorized errors, you can use the `JwtBearerEvents`
55
55
The `JwtBearerEvents` class has the following callback properties (invoked in the following order) that can help us debug these 401 Access Denied or UnAuthorization issues:
56
56
57
57
-[`OnMessageRecieved`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onmessagereceived?view=aspnetcore-2.2#Microsoft_AspNetCore_Authentication_JwtBearer_JwtBearerEvents_OnMessageReceived) is called first for every request.
58
-
-[`OnAuthenticationFailed`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onauthenticationfailed?view=aspnetcore-2.2) is called when the token does not pass the application's token validation criteria.
58
+
-[`OnAuthenticationFailed`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onauthenticationfailed?view=aspnetcore-2.2) is called when the token doesn't pass the application's token validation criteria.
59
59
-[`OnChallenge`](/dotnet/api/microsoft.aspnetcore.authentication.jwtbearer.jwtbearerevents.onchallenge?view=aspnetcore-2.2) is called last before a 401 response is returned.
60
60
61
61
### Step 1: Enable PII logging
@@ -164,7 +164,7 @@ public void ConfigureServices(IServiceCollection services)
164
164
```
165
165
### Sample results
166
166
167
-
With the above implementation, when a 401 Unauthorized error occurs, the response output should include detailed error messages, such as:
167
+
With the implementation, when a 401 Unauthorized error occurs, the response output should include detailed error messages, such as:
0 commit comments