Token not returning from samsung smart tv remote control API

431 Views Asked by At

I want to develop a Remote control for iOS devices. For that, I am using the below API to get a token from Samsung TV but it's not returning me Token which I can use for further Remote control commands. ws://192.168.29.53:8001/api/v2/channels/samsung.remote.control?name=U2Ftc3VuZ1JlbW90ZUFwcA==

I am able to get connected TV information by iOS SDK. My TV and app are connected to the same network connection.

The above API gives me the response as below:

{ "event": "ms.channel.connect", "data": { "id": "9bcfee40-66a0-11ee-885d-ed03655c04c0", "clients": [ { "id": "9bcfee40-66a0-11ee-885d-ed03655c04c0", "connectTime": 1696855048996, "attributes": { "name": "U2Ftc3VuZ1JlbW90ZUFwcA==" }, "deviceName": "U2Ftc3VuZ1JlbW90ZUFwcA==", "isHost": false } ] } }

Can anyone help me out by getting a token from a connected socket?

I tried both port 8002 and 8001 but I am getting device info with only 8001 and with ws://

2

There are 2 best solutions below

1
AudioBubble On

Create the token on their website and then include the token in your request. Try with this: https://developer.smartthings.com/docs/advanced/authorization-and-permissions#:~:text=To%20generate%20a%20Personal%20Access,%22Personal%20Access%20Tokens%22%20page. I don't know if you're doing it on Swift (you used the Swift tag) but would be nice if you included some extra code to see exactly what you're doing.

0
VishV_dev On

First check, is Your device supports token Auth Support or not by using this URL.

curl --location 'http://YourIP:8001/api/v2/'

Then if it give you true then use this provided webSocket URL,

wss://YourIP:8002/api/v2/channels/samsung.remote.control?name="encodedAppName"

And if you got false then use this webSocket URL,

ws://YourIP:8001/api/v2/channels/samsung.remote.control?name="encodedAppName"

as the response of this webSocket, you will get a authToken which you need to store for future like for fire the commands by using this webSocket URL.

wss://YourIP:8002/api/v2/channels/samsung.remote.control?name="encodedAppName"&token="generatedAuthToken"