> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kavachos.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Railway

> Authenticate users via Railway OAuth 2.0. Register an app in Railway settings, set the redirect URI, and configure `read:profile` and `read:email` scopes.

## Setup

<Steps>
  <Step>
    ### Get credentials

    Go to [railway.com](https://railway.com) and navigate to **Account Settings > Developer > OAuth Apps**. Create an app and add your redirect URI:

    ```
    https://your-app.com/api/kavach/auth/oauth/callback/railway
    ```
  </Step>

  <Step>
    ### Configure

    ```ts title="lib/kavach.ts" theme={"system"}
    import { createKavach } from 'kavachos';
    import { oauth } from 'kavachos/auth';

    const kavach = await createKavach({
      database: { provider: 'sqlite', url: 'kavach.db' },
      plugins: [
        oauth({
          providers: [
            {
              id: 'railway',
              clientId: process.env.RAILWAY_CLIENT_ID!,
              clientSecret: process.env.RAILWAY_CLIENT_SECRET!,
            },
          ],
        }),
      ],
    });
    ```

    ```bash theme={"system"}
    RAILWAY_CLIENT_ID=...
    RAILWAY_CLIENT_SECRET=...
    ```
  </Step>
</Steps>

## Scopes

Default scopes: `read:profile`, `read:email`

| Scope           | What it unlocks    |
| --------------- | ------------------ |
| `read:profile`  | Read user profile  |
| `read:email`    | Read email address |
| `read:projects` | Read project list  |

## Endpoints

| Method | Path                            | Description         |
| ------ | ------------------------------- | ------------------- |
| GET    | `/auth/oauth/authorize/railway` | Redirect to Railway |
| GET    | `/auth/oauth/callback/railway`  | Handle callback     |
