# Microsoft.Owin.Security.OpenIdConnect

**Kind:** Service

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

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

NuGet package dependency

`Microsoft.Owin.Security.OpenIdConnect` is a NuGet dependency referenced by the Pams API project for OpenID Connect authentication in the OWIN middleware pipeline. It handles authentication challenges, identity-provider redirects, and processing of OpenID Connect sign-in responses before requests reach protected API endpoints.

## Diagram

```mermaid
sequenceDiagram
    participant Client as JavaScript Client
    participant Api as Pams API
    participant Owin as OWIN OpenID Connect Middleware
    participant IdentityProvider as Identity Provider

    Client->>Api: Request protected endpoint
    Api->>Owin: Authentication challenge
    Owin->>IdentityProvider: Redirect for sign-in
    IdentityProvider->>Owin: OpenID Connect response
    Owin->>Api: Set authenticated principal
    Api->>Client: Return protected response
```

## Usage

```ts
async function loadProtectedData(accessToken: string) {
  const response = await fetch("/api/protected-resource", {
    headers: {
      Authorization: `Bearer ${accessToken}`,
      Accept: "application/json",
    },
  });

  if (!response.ok) {
    throw new Error(`Request failed: ${response.status}`);
  }

  return response.json();
}
```

## AI Coding Instructions

- Keep OpenID Connect middleware configuration in the API startup path where the OWIN authentication pipeline is registered.
- Match the client redirect URI and authentication settings with the configured identity provider values.
- Send access tokens through the `Authorization: Bearer` request header when calling protected API routes.
- Do not place identity-provider secrets, client secrets, or tokens in browser source code.

## Used by

1 reference from 1 file. 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 (1)

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