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

# OAuth and Serve Account Linking for Router

> Start OAuth login with POST /v1/router/auth/oauth/start and complete it via callback. Link and update Aria Compute Serve accounts.

Aria Compute ROUTER supports OAuth-based authentication and linking to an Aria Compute Serve account. Use the OAuth start endpoint to redirect users to an identity provider, then handle the callback to establish a session. Linked Serve account information can be viewed and updated through dedicated management endpoints.

## Start OAuth Flow

Initiate an OAuth authorization request.

### Endpoint

```http theme={null}
POST /v1/router/auth/oauth/start
```

### Authentication

No authentication required.

### Request Body

<ParamField body="provider" type="string" required>
  Name of the OAuth provider to use.
</ParamField>

### Response

<ResponseField name="authorize_url" type="string">
  URL to redirect the user to for provider authorization.
</ResponseField>

<ResponseField name="state" type="string">
  OAuth state parameter for CSRF protection.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://router.example.com:8080/v1/router/auth/oauth/start \
    -H "Content-Type: application/json" \
    -d '{"provider":"google"}'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "authorize_url": "https://accounts.google.com/o/oauth2/v2/auth?...",
    "state": "abc123xyz"
  }
  ```
</ResponseExample>

## OAuth Callback

Complete the OAuth flow after the user authorizes with the provider.

### Endpoint

```http theme={null}
GET /v1/router/auth/oauth/callback?code=<code>&state=<state>
```

### Authentication

No authentication required. The callback exchanges the authorization code for a session and sets the session cookie.

### Query Parameters

<ParamField query="code" type="string" required>
  Authorization code returned by the OAuth provider.
</ParamField>

<ParamField query="state" type="string" required>
  State value returned by the OAuth provider, used to validate the request.
</ParamField>

### Response

A successful callback sets the session cookie and returns user summary fields.

<RequestExample>
  ```bash cURL theme={null}
  curl "https://router.example.com:8080/v1/router/auth/oauth/callback?code=AUTHCODE&state=abc123xyz" \
    -c cookies.txt
  ```
</RequestExample>

## Serve Account

View or update the Aria Compute Serve account linked to the current Router user.

### Get Linked Account

```http theme={null}
GET /v1/router/serve/account
```

#### Authentication

Send the session cookie or `Authorization: Bearer <api-key>`.

#### Response

<ResponseField name="account_id" type="string">
  Identifier of the linked Serve account.
</ResponseField>

<ResponseField name="email" type="string">
  Email associated with the linked Serve account.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl https://router.example.com:8080/v1/router/serve/account \
    -H "Authorization: Bearer <api-key>"
  ```
</RequestExample>

### Update Linked Account

```http theme={null}
PUT /v1/router/serve/account
```

#### Authentication

Send the session cookie or `Authorization: Bearer <api-key>`.

#### Request Body

<ParamField body="account_id" type="string" required>
  New Serve account identifier to link.
</ParamField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X PUT https://router.example.com:8080/v1/router/serve/account \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer <api-key>" \
    -d '{"account_id":"serve-acc-456"}'
  ```
</RequestExample>


## Related topics

- [Register Account on Aria Compute ROUTER](/api-reference/router/auth/register.md)
- [Authenticate with Aria Compute ROUTER](/api-reference/router/authentication.md)
- [Get started with Aria Compute in minutes](/quickstart.md)
- [Authenticate requests to the Aria Compute API](/authentication.md)
- [Update Aria Compute ROUTER Email Address](/api-reference/router/auth/email.md)
