WebSocket Authentication?

  • 1
  • Question
  • Updated 3 months ago
I sent this same message to developer@automatic.com 5 days ago, but haven't received a response yet. I'm hoping to get a response here.


I'm working on a plugin (Automatic Indigo Plugin), and I have some questions. 

First, it doesn't look like my request to refresh my token works. I always get back:

{"detail":"Invalid refresh_token","error":"err_invalid_refresh_token"}


I am fairly certain the my request is correct. Does the refresh request not work while in developer mode?


Next, I'm not sure that I'm going to make use of the Websocket or Webhook features. If I do, it definitely won't be the Webhook - that won't work for my application. However, it's possible that the Websocket could work quite well for me. Should I implement it, I don't understand how the Websocket request would know it's "me". If I understand it correctly, the client_id and client_secret are static for my app. When I do the oauth piece, I'd get an access_token, which I would assume would tie my app to the user. However, based on the documentation, the Websocket request only takes in the client_id and the client_secret. If that's the case, how does the Websocket know which users data to send to the socket? Am I missing something?


Finally, if I only use the API calls, how would I be able to recreate the information like I get on my Apple Watch - knowing when a trip began, when a trip ended, the location of the end of the trip, knowing when a DTC is available. Can I get all that by pinging the API every minute?


Thanks,

Dave

Photo of David Garozzo

David Garozzo

  • 180 Points 100 badge 2x thumb

Posted 8 months ago

  • 1
Photo of Derrick S.

Derrick S., Official Rep

  • 6,964 Points 5k badge 2x thumb
Hi Dave,

Sorry you haven't heard back from them. Unfortunately I don't have the answer to your question and that team will. I will ping them to get back to you.
Photo of David Garozzo

David Garozzo

  • 180 Points 100 badge 2x thumb
Still no response. :(
Photo of Fleet Developer

Fleet Developer

  • 120 Points 100 badge 2x thumb
I have the same question. WebSocket API call is taking only clientId, clientsecret which we pass with the WebSocket URL. There is no place to enter access token. So wondering if OAuth authentication is even needed if I do the WebSocket API approach? Can you please let me know?
Photo of Justin Rodino

Justin Rodino

  • 820 Points 500 badge 2x thumb
David,

Are you sure sockets are what you want? Why not have a web hook sent to you upon trip completion if that's all of the data you're looking for? Much easier to implement :) The webhook will send you all of the trip data including the polyline of the full trip...
(Edited)
Photo of Sara kam

Sara kam

  • 100 Points 100 badge 2x thumb
Can u pls reply as to whether Authentication is needed if we use WbSocket API? For RestAPI we use OAuth and then use the accesstoken and all works great. We are now looking to use WebSocket for maps data and WebSocket connection is always failing. How do we pass accesstoken(WebSocket API is taking only clientid, clientsecret)?
Photo of David Garozzo

David Garozzo

  • 180 Points 100 badge 2x thumb
When your users do their OAuth request, it grants Automatic permission to share that specific user's Automatic data with your service.

Automatic's implementation requires you to take ownership of all of your users' WebSocket events. That is, they want you to have a single service in place that would handle doing the WebSocket API. That single service would be responsible for receiving all of your users' events, and distributing them to your users. Automatic does not expect each of your users to be making their own calls to the WebSocket API.

Hopefully I've explained that clear enough.
Photo of Sara kam

Sara kam

  • 100 Points 100 badge 2x thumb
Hi,

I used this websocket URL to connect:

https://stream.automatic.com?token=clientid:clientsecret

I've tried to make websocket connection right after I get access token but I get error saying below messge. Wondering if you can please comment as to why I get this? I have accesstoken but don't see a way to pass it, so curious? Appreciate your help.

"Error initializing handshake with https://stream.automatic.com/?token=XX:XX"
Photo of David Garozzo

David Garozzo

  • 180 Points 100 badge 2x thumb
You don't need to pass in your access token for web socket use.

You're using a SocketIO library to make the connection, right?

On developer.automatic.com, did you configure your app to use WebSocket for Event Delivery Preference?

Also, if you plan on getting map info, make sure you request real time location data be added to your access token list.
Photo of Sara kam

Sara kam

  • 100 Points 100 badge 2x thumb
Thanks for the help. Got this to work yesterday.