# Microsoft.IdentityModel.Tokens

**Kind:** Service

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

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

NuGet package dependency

`Microsoft.IdentityModel.Tokens` is a NuGet dependency referenced by `Pams.API`. It supplies token validation types and cryptographic key handling used when the API checks authentication tokens.

## Diagram

```mermaid
sequenceDiagram
    participant Client
    participant API as Pams.API
    participant Tokens as Microsoft.IdentityModel.Tokens

    Client->>API: Request with Authorization bearer token
    API->>Tokens: Validate token signature and claims
    Tokens-->>API: Validation result
    API-->>Client: Authenticated response or authorization error
```

## Usage

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

if (!response.ok) {
  throw new Error("API request was not authorized");
}

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

## AI Coding Instructions

- Keep `Microsoft.IdentityModel.Tokens` configuration in the API authentication setup rather than in client-side code.
- Pass token validation parameters through the existing authentication pipeline.
- Ensure signing keys, issuers, and audiences match the identity provider configuration.
- Do not log bearer tokens, signing keys, or token validation details in API responses.
