# login_chatgpt_device

> **Function** in `langchain_openai`

📖 [View in docs](https://reference.langchain.com/python/langchain-openai/chatgpt_oauth/login_chatgpt_device)

Run the ChatGPT device-code OAuth flow.

This is the headless fallback for environments without a browser. The
function prints a verification URL and user code, polls for completion,
then exchanges the resulting code via the OAuth token endpoint using
`CHATGPT_DEVICE_REDIRECT_URI`.

## Signature

```python
login_chatgpt_device(
    *,
    store_path: Path | None = None,
    client_id: str = CHATGPT_CLIENT_ID,
    poll_interval: float = 5.0,
    timeout: float = 600.0,
) -> _FileChatGPTOAuthTokenProvider
```

## Description

**See Also:**

`login_chatgpt`: Browser-based loopback flow preferred when a local
browser and free callback port are available.

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `store_path` | `Path \| None` | No | Where to persist the token. Defaults to `DEFAULT_STORE_PATH`. (default: `None`) |
| `client_id` | `str` | No | OAuth client ID (defaults to Codex/ChatGPT client). (default: `CHATGPT_CLIENT_ID`) |
| `poll_interval` | `float` | No | Seconds between polls. (default: `5.0`) |
| `timeout` | `float` | No | Total seconds to wait. (default: `600.0`) |

## Returns

`_FileChatGPTOAuthTokenProvider`

A configured `_FileChatGPTOAuthTokenProvider`.

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/1c6bfc8f608581f889a8dc625402234ff72d1cd3/libs/partners/openai/langchain_openai/chatgpt_oauth.py#L959)