# Microsoft.Owin.Security.Twitter

**Kind:** Service

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

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

NuGet package dependency

The `Microsoft.Owin.Security.Twitter` NuGet dependency supplies Twitter authentication middleware to the legacy-format Pams API project. The API configures the middleware, redirects sign-in requests to Twitter, and processes the callback to establish an authenticated OWIN identity.

## Diagram

```mermaid
sequenceDiagram
    participant Browser
    participant PamsAPI as Pams API
    participant Twitter

    Browser->>PamsAPI: Request Twitter sign-in endpoint
    PamsAPI->>Twitter: Redirect with authentication request
    Twitter->>Browser: Request user authorization
    Browser->>Twitter: Approve authorization
    Twitter->>PamsAPI: Return to configured callback endpoint
    PamsAPI->>PamsAPI: Create OWIN authentication identity
    PamsAPI->>Browser: Redirect to application route
```

## Usage

```ts
function signInWithTwitter(): void {
  // This endpoint must match the Twitter authentication route
  // configured in the Pams API OWIN startup code.
  window.location.assign("/signin-twitter");
}

document
  .querySelector<HTMLButtonElement>("#twitter-sign-in")
  ?.addEventListener("click", signInWithTwitter);
```

## AI Coding Instructions

- Keep the `Microsoft.Owin.Security.Twitter` package reference in the Pams API `.csproj` file using its existing legacy project format.
- Configure the Twitter middleware in the OWIN startup pipeline before routes that require authenticated users.
- Store Twitter consumer credentials outside source control and load them through application configuration.
- Ensure the callback URL configured in Twitter matches the callback path handled by the API.
- Treat the browser sign-in endpoint as a redirect flow; do not call it with an AJAX request.

## 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
