-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use jwt token in WSClient #92
Comments
Thank you for reporting! If this is an SDK specific issue, we will look into it and get back to you soon. If this is an API related request, report it in our Advanced API Discord instead (use this invite link if it's your first time accessing the Discord). |
The JWT token will be automatically generated when you subscribe to channels using the WSClient. There is no need to generate it yourself. |
I realized I will get {"type":"error","message":"authentication failure"} if I try to subscribe to the 'heartbeat' channel, subscribing to other channels is fine. Could you please explain why this is? What does the 'heartbeat' channel do, and why the auth failure? I can use the REST requests just fine. |
Heartbeats channel does not require authentication. More details in our docs here: https://docs.cdp.coinbase.com/advanced-trade/docs/ws-channels#heartbeats-channel It's possible you have a typo. Try using 'heartbeats' rather than 'heartbeat' |
I am trying to use the WSClient to get data, however, I am getting {"type":"error","message":"authentication failure"}.
My understanding is that I need a jwt token, which I got from
jwt_token = jwt_generator.build_ws_jwt(api_key, api_secret)
However, I do not know how to use this token in my WSClient, my code is as follows
self.ws_client = WSClient(api_key=api_key, api_secret=api_secret, on_message=self.on_message, verbose=True)
self.ws_client.open()
self.ws_client.subscribe(product_ids=[product_id], channels=channels)
Could anyone please help me with this?
The text was updated successfully, but these errors were encountered: