# Microsoft.IdentityModel.JsonWebTokens

**Kind:** Service

**Source:** `Pams/Logic/Pams.Business/Pams.Business.csproj` (line 1)

**Part of:** [Pams](subsystem-pams)

NuGet package dependency

`Microsoft.IdentityModel.JsonWebTokens` is a NuGet dependency referenced by `Pams.Business.csproj` for reading and validating JSON Web Tokens in the business layer. It supports authentication flows by checking token contents and validation results before protected business operations run.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant API
    participant PamsBusiness as Pams.Business
    participant JsonWebTokens as Microsoft.IdentityModel.JsonWebTokens

    Client->>API: Send request with Bearer token
    API->>PamsBusiness: Pass authentication context
    PamsBusiness->>JsonWebTokens: Read and validate token
    JsonWebTokens-->>PamsBusiness: Return token validation result
    PamsBusiness-->>API: Allow or reject operation
    API-->>Client: Return response
```

## Usage

```ts
const response = await fetch("/api/pams/records", {
  headers: {
    Authorization: `Bearer ${accessToken}`,
    Accept: "application/json",
  },
});

if (!response.ok) {
  throw new Error("The API rejected the request or token.");
}

const records = await response.json();
console.log(records);
```

## AI Coding Instructions

- Keep token parsing and validation inside the .NET authentication or business-layer flow; JavaScript clients should send tokens through the `Authorization` header.
- Confirm that `Pams.Business.csproj` contains the package reference before adding code that depends on `Microsoft.IdentityModel.JsonWebTokens`.
- Do not trust token claims until the configured validation process accepts the token.
- Preserve the existing authentication context when passing requests from API handlers into business services.

## Used by

2 references from 2 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Injected or called by (2)

- `Pams.API` — `Pams/API/Pams.API/Pams.API.csproj`:1
- `Pams.Business` — `Pams/Logic/Pams.Business/Pams.Business.csproj`:1
