--- title: "Generate Token Pair" url: https://docs.catalyst.zoho.com/en/sdk/python/v1/cloud-scale/data-streams/generate-token-pair/ description: "This page describes the methods to generate WebSocket access tokens for subscribers in your Python application with sample code snippets." last_updated: 2026-08-13T11:41:55Z service: Cloud Scale type: general related_links: - name: "Data Streams Help" url: /en/cloud-scale/help/data-streams/introduction - name: "SDK Scopes" url: /en/sdk/python/v1/sdk-scopes --- # Generate Token Pair Before a client can subscribe to a [Data Streams](https://docs.catalyst.zoho.com/en/cloud-scale/help/data-streams/introduction/) channel, it must obtain a token pair to authenticate the WebSocket connection. The token pair can be generated using either a user ID or a connection name. You can generate the token pair in two ways as described in this section. The `data_streams` reference used below is the component instance created earlier. To know more about this instance, please refer to [this section](https://docs.catalyst.zoho.com/en/sdk/python/v1/cloud-scale/data-streams/get-component-instance/). ### Get Token Pair using User ID This method generates a token pair by passing the channel ID and the user ID to the `get_token_pair()` method. The user ID represents the unique identifier of the application user who is subscribing to the channel. **Parameters Used**
Parameter Name Data Type Definition
`channel_id` String A **Mandatory** parameter. Holds the unique ID of the channel.
`user_id` String A **Mandatory** parameter. Holds the unique ID of the user subscribing to the channel.
```python # Get token pair using user id token_by_user = data_streams.get_token_pair("CHANNEL_ID", user_id="USER_ID") ``` ### Get Token Pair using Connection Name This method generates a token pair by passing the channel ID and a connection name to the `get_token_pair()` method. The connection name is a custom identifier for the subscriber connection. **Parameters Used**
Parameter Name Data Type Definition
`channel_id` String A **Mandatory** parameter. Holds the unique ID of the channel.
`connection_name` String A **Mandatory** parameter. Holds the custom identifier for the subscriber connection.
```python # Get token pair using connection name token_by_connection = data_streams.get_token_pair("CHANNEL_ID", connection_name="CONNECTION_NAME") ```