Auth ok, but sub failing with: -300 Please provide valid token

I am facing the following error:

Response: {'type': 'cn', 'code': 200, 'message': 'Authentication done', 's': 'ok'} Response: {'type': 'ful', 'code': 200, 'message': 'Full Mode On', 's': 'ok'} Error: {'code': -300, 'message': 'Please provide valid token', 's': 'error', 'type': 'sub'}

the code is usual code:

from fyers_apiv3.FyersWebsocket import data_ws
def onmessage(message):
print("Response:", message)
def onerror(message):
print("Error:", message)
def onclose(message):
print("Connection closed:", message)
def onopen():
 data_type = "SymbolUpdate"
 symbols = ['NSE:SBIN-EQ', 'NSE:ADANIENT-EQ']
 fyers.subscribe(symbols=symbols, data_type=data_type)
 fyers.keep_running()
# Create a FyersDataSocket instance with the provided parameters
fyers = data_ws.FyersDataSocket(
access_token=access_token, # Access token in the format "appid:accesstoken"
log_path="", # Path to save logs. Leave empty to auto-create logs in the current directory.
litemode=False, # Lite mode disabled. Set to True if you want a lite response.
write_to_file=False, # Save response in a log file instead of printing it.
reconnect=True, # Enable auto-reconnection to WebSocket on disconnection.
on_connect=onopen, # Callback function to subscribe to data upon connection.
on_close=onclose, # Callback function to handle WebSocket connection close events.
on_error=onerror, # Callback function to handle WebSocket errors.
on_message=onmessage # Callback function to handle incoming messages from the WebSocket.
)
fyers.connect()

1 reply