如何在没有预共享密钥的情况下使用 Sony Bravia TV IP Control 进行身份验证

K A*_*ahi 5 authentication sony

本指南 ( https://pro-bravia.sony.net/develop/integrate/ip-control/ ) 介绍了如何通过在电视菜单中设置预共享密钥并使用标头 (X-Auth-PSK: [Pre-Shared Key])与请求。

除了我的应用程序之外,其他应用程序会在网络上发现我的电视,电视上会弹出一个(一次性)PIN,然后由用户在客户端输入(例如远程应用程序)。此身份验证流程如何运作?我自己该如何实施呢?

Ant*_*ist 3

您可以通过执行以下代码来调用身份验证,首先在浏览器中打开一个选项卡并输入电视的IP地址,这样当您通过控制台执行此代码时就不会收到CORS错误。

var tvIPAddress = '192.168.0.16'; // the IP of the TV
var id = 1001; // random integer number ( that will be assigned to your control device )

var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://'+tvIPAddress+'/sony/accessControl');
xhr.send(JSON.stringify(
{method: "actRegister",
  version: "1.0",
  id: id,
  params: [{ clientid: "DEVICE NAME: RANDOM-CLIENT-ID-XXXXXXXXXX" , nickname: "YOUR-DEVICE-NAME" },[{function:"WOL",value:"no"}]]
  }
));
Run Code Online (Sandbox Code Playgroud)

然后在弹出窗口中输入电视上的 PIN 码作为密码。将用户名字段留空。

然后你可以像这样发送 IRCC 命令:

var code = "AAAAAQAAAAEAAAASAw=="; // volume up

xhr.open('POST', 'http://192.168.0.16/sony/IRCC');
xhr.setRequestHeader('SOAPACTION', "urn:schemas-sony-com:service:IRCC:1#X_SendIRCC");
xhr.send('<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:X_SendIRCC xmlns:u="urn:schemas-sony-com:service:IRCC:1"><IRCCCode>'+code+'</IRCCCode></u:X_SendIRCC></s:Body></s:Envelope>');
Run Code Online (Sandbox Code Playgroud)

您可以在这里找到更多信息: https://pro-bravia.sony.net/develop/integrate/ircc-ip/overview/index.html