Error to connect the websocket client

I am using Websocket client to fetch market data.
The same sample code I implemented with the API token as provided.But it is still giving me the error saying API_exception 401 and reason: unauthorized and ‘Invalid token used to access API’ and many more!!
Link to sample code provided by Upstox:

@Atharva

You encountered the error message ‘Invalid token used to access API’ while attempting to connect to the websocket. This issue typically arises when the access token used for API access is invalid. To resolve this, please go through the OAuth flow to generate a new access token and then attempt to reconnect to the websocket with this new token. A successful connection should be established once a valid access token is provided.

For further details on error codes and their interpretations, please consult the documentation at Error codes | Upstox Developer API.

Thank you!

I am using the correct token key as provided by the upstox and still the issue is not solved.Is there anything wrong while creating it or are there any procedure to follow while creating tokens?.

@Atharva

Should you continue to encounter the ‘Invalid token used to access API’ error, it’s evident that the access token you’re utilizing is not valid at the time of use.

I recommend adhering to the guidelines provided in this documentation to create a new access token: Authentication | Upstox Developer API.

Thank you!

Still getting error! while the API is valid at the time.
Is there something wrong I am doing while generating an API key.
What should be the redirect URL while generating an API key, am I doing it correctly.

@Atharva

Could you please provide a detailed explanation of the entire process? It would be particularly helpful if you could include a CURL sample for clarity.

Thanks a lot!

I want to fetch the live market data and so I am using the concept of Websockets.As sample implementation provided by the upstox i am also implementing the same program and just changing the API token Key as per the instructions .But after changing its showing ERROR despite following the every process given by the documentation of Upstox.
The error code is 401 and showing that invalid token used to access the API.
While creating the api token my redirect url was (https://127.0.0.1:5050/) and i also tried with (https://localhost)

@Atharva,

Should you continue to encounter issues with the token, I recommend testing the access_token with a different Upstox API. This approach will aid in pinpointing the problem. If the access_token functions correctly with other APIs but not the one in question, kindly share your code with us for a brief review.

Thank you!