> This page is for Web API.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://ibkrcampus.com/docs/llms.txt.

# Establishing the Websocket with OAuth

The process for those authenticating with OAuth is similar, though slightly different. In addition to the API cookie, you must also include the "oauth_token" query param which should be set to the user's access token value.

#### Python

```python
ws = websocket.WebSocketApp(
  url="wss://api.ibkr.com/v1/api/ws?oauth_token={accessToken}",
  on_open=on_open,
  on_message=on_message,
  on_error=on_error,
  on_close=on_close,
  cookie=f"api={sessionToken}"
)
ws.run_forever()
```

#### Generic

```generic
curl -i -N -H "Connection: Upgrade" -H "Upgrade: websocket" -H --cookie "api=d21b8cf5ebc8ea01c6ce37c8125ec83f" wss://api.ibkr.com/v1/api/ws?oauth_token={Access Token}
```