# OAuth2 Token Response

> OAuth 2.0 token endpoint response with access token, type, and optional refresh token.

- Name: `oauth2-token-response`
- Categories: auth
- Detail page: https://open-types.dev/types/oauth2-token-response

## Install

```bash
# Types only
npx shadcn add @open-types/oauth2-token-response

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

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

## Types

```typescript
export interface OAuth2TokenResponse {
  access_token: string;
  token_type: string;
  expires_in?: number;
  refresh_token?: string;
  scope?: string;
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { OAuth2TokenResponse } from "../types/oauth2-token-response";

export const oauth2TokenResponseSchema = z.object({
  access_token: z.string(),
  token_type: z.string(),
  expires_in: z.number().int().optional(),
  refresh_token: z.string().optional(),
  scope: z.string().optional(),
}) satisfies z.ZodType<OAuth2TokenResponse>;

export type { OAuth2TokenResponse } from "../types/oauth2-token-response";
```

## Examples

```typescript
// Source: https://datatracker.ietf.org/doc/html/rfc6749#section-5.1
// Captured: 2026-05
import type { OAuth2TokenResponse } from "../types/oauth2-token-response";

export const oauth2TokenResponseExamples = {
  bearerFull: {
    access_token: "2YotnFZFEjr1zCsicMWpAA",
    token_type: "Bearer",
    expires_in: 3600,
    refresh_token: "tGzv3JOkF0XG5Qx2TlKWIA",
    scope: "read write profile",
  } satisfies OAuth2TokenResponse,
  bearerMinimal: {
    access_token: "abc123XYZ.def456UVW",
    token_type: "Bearer",
  } satisfies OAuth2TokenResponse,
  shortLived: {
    access_token: "short-lived-token-001",
    token_type: "Bearer",
    expires_in: 60,
  } satisfies OAuth2TokenResponse,
  noRefresh: {
    access_token: "client-credentials-token-xyz",
    token_type: "Bearer",
    expires_in: 3600,
    scope: "api:read",
  } satisfies OAuth2TokenResponse,
  mac: {
    access_token: "mac-style-token",
    token_type: "mac",
    expires_in: 7200,
  } satisfies OAuth2TokenResponse,
} as const;
```
