Search code examples
nest-api

How to send access token using a wss .net client


I want to connect to the nest endpoint using a .net wss client. I am unsure how to pass the NEST access_token during handshake to the endpoint to complete the authorization handshake.

  • Without it I get a 401.
  • If I put is as query parameter "/devices.json?auth=c.Uysdi..." I get a 307 (redirection) to a firebase endpoint but with https ??? (no longer wss).
  • If i add the access token to headers I get 401.

In the api samples I can only find javascript examples using firebase client lib which does not help much. Can someone explain what should I do to complete the wss handshake ?


Solution

  • I found out what was the problem.

    There was a 'bug' in the web socket library I was using. The header value "Upgrade: websocket" which is passed during websocket handshake was passed like this "Upgrade: webSocket". Some websocket test servers are case insensitive but not the one from Google Nest. Once I changed this to "websocket" I got a proper websocket handshake response and no redirection either.
    Access token is added as a query parameter when connecting with websockets to the nest endpoint.

    Once the connection is established I am again in the dark on how to establish subscribtion to certain events or query data but this will be the topic for another question.