# OAuth2 Authorization Request

> OAuth 2.0 authorization request parameters with response type, client ID, and scope.

- Name: `oauth2-authorization-request`
- Categories: auth
- Detail page: https://open-types.dev/types/oauth2-authorization-request

## Install

```bash
# Types only
npx shadcn add @open-types/oauth2-authorization-request

# Types + Zod v4 validators
npx shadcn add @open-types/oauth2-authorization-request-zod

# Types + real-world examples
npx shadcn add @open-types/oauth2-authorization-request-examples
```

## Types

```typescript
export interface OAuth2AuthorizationRequest {
  response_type: string;
  client_id: string;
  redirect_uri?: string;
  scope?: string;
  state?: string;
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { OAuth2AuthorizationRequest } from "../types/oauth2-authorization-request";

export const oauth2AuthorizationRequestSchema = z.object({
  response_type: z.string(),
  client_id: z.string(),
  redirect_uri: z.string().optional(),
  scope: z.string().optional(),
  state: z.string().optional(),
}) satisfies z.ZodType<OAuth2AuthorizationRequest>;

export type { OAuth2AuthorizationRequest } from "../types/oauth2-authorization-request";
```

## Examples

```typescript
// Source: https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.1
// Captured: 2026-05
import type { OAuth2AuthorizationRequest } from "../types/oauth2-authorization-request";

export const oauth2AuthorizationRequestExamples = {
  authCodeFlow: {
    response_type: "code",
    client_id: "client-1234567890abcdef",
    redirect_uri: "https://app.example.com/callback",
    scope: "openid email profile",
    state: "xyz-csrf-token-9876",
  } satisfies OAuth2AuthorizationRequest,
  implicitFlow: {
    response_type: "token",
    client_id: "client-1234567890abcdef",
    redirect_uri: "https://app.example.com/callback",
    scope: "read:profile",
    state: "abc-csrf-token-1234",
  } satisfies OAuth2AuthorizationRequest,
  minimalAuthCode: {
    response_type: "code",
    client_id: "client-1234567890abcdef",
  } satisfies OAuth2AuthorizationRequest,
  pkceFlow: {
    response_type: "code",
    client_id: "spa-client",
    redirect_uri: "https://app.example.com/callback",
    scope: "openid profile",
    state: "pkce-state-456",
  } satisfies OAuth2AuthorizationRequest,
} as const;
```
