Closed xuncia closed 8 years ago
Hm, it seems to work alright judging from your log. Can you run each step from auth.sh manually to see where it breaks? The script is not very complicated, it's mostly tying the tools together.
On December 31, 2015 3:56:10 PM GMT+01:00, xuncia notifications@github.com wrote:
Hi, I was trying on OSX and the first script gives me:
sh authsh
Trying to register on ?? {"error":[401,"Unauthorized"],"id":8}
Response should contain an "Unauthorized" error and the TV should display a dialog with a 4-digit PIN A message with "Registration has been cancelled" after this step means that the UUID seems to be registered already Delete old registered devices in: Settings → Network → Home Network Setup → Remote Device / Renderer → Registered Remote Devices
Okay, now enter the 4-digit code shown on the TV: 3202
Trying to register on 1921681119, this time with the given code…
It seems that the cookie is not created, and indeed after the second script
the print_icc , the result is :
auth_cookie not found Run /authsh first
Do you have any idea? I'm using a BRAVIA KDL 50W829B
thanks
Reply to this email directly or view it on GitHub: https://github.com/breunigs/bravia-auth-and-remote/issues/4
Hi, yes i tested and the step is this on:
cookie=$(curl --include --silent -XPOST http://192.168.1.119/sony/accessControl --header "7208" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:B56D71AF-A306-45CA-A280-194A4A81F5C4\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}" | grep -o -E 'auth=([a-z0-9]+)')
but it's not crashing...I receiving a message from my sony that the request is remotely canceled.... It make sense because running the original script I never receive this message:
echo "If everything worked, you should see an auth=<code> line above."
echo "Your computer is now registered, use it like this:"
any idea?
The example you pasted here is incorrect -- the --header
option just contains 7208
, even though it should be something along the lines of Authorization: Basic OjcyMDg=
. The last bit is :7208
base64 encoded.
Can you paste the output of:
echo -n ":7208" | base64
If that equals OjcyMDg=
, try the next step manually. First, try to get the TV to display the PIN code, then base64 encode in manually and insert it here:
curl --include -v -XPOST http://192.168.1.119/sony/accessControl --header "Authorization: Basic PLACE_BASE64_HERE" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:B56D71AF-A306-45CA-A280-194A4A81F5C4\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}"
Nopaste the output or look for an auth=
line. The alphanumeric stuff after the equal should be your auth_cookie.
Yes you are right I didn't checked the base24 with the base24 codification I have this result:
curl --include -v -XPOST http://192.168.1.119/sony/accessControl --header "Authorization: Basic OjYwNDM=" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:B56D71AF-A306-45CA-A280-194A4A81F5C4\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}"
* Trying 192.168.1.119...
* Connected to 192.168.1.119 (192.168.1.119) port 80 (#0)
> POST /sony/accessControl HTTP/1.1
> Host: 192.168.1.119
> User-Agent: curl/7.43.0
> Accept: */*
> Authorization: Basic OjYwNDM=
> Content-Length: 193
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 193 out of 193 bytes
< HTTP/1.1 503 Service Unavailable
HTTP/1.1 503 Service Unavailable
< Content-Type: application/json
Content-Type: application/json
< Content-Length: 44
Content-Length: 44
< Connection: keep-alive
Connection: keep-alive
< Date: Fri, 01 Jan 2016 19:56:33 GMT
Date: Fri, 01 Jan 2016 19:56:33 GMT
<
* Connection #0 to host 192.168.1.119 left intact
{"error":[503,"Service Unavailable"],"id":8}
hrm. Which TV do you own exactly? The only difference from the command I am using that I can see is that my uuid is in lowercase. So, basically you can try if this works:
curl --include -v -XPOST http://192.168.1.119/sony/accessControl --header "Authorization: Basic PLACE_BASE64_HERE" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:b56d71af-a306-45ca-a280-194a4a81f5c4\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}"
I only changed the UUID to lower case here. You still have to do the PIN stuff like before, of course.\
…and if that doesn't work. Maybe the TV uses a slightly different protocol? The only way to check that would be to sniff the traffic between the TV and your mobile phone while pairing the official Sony app, using e.g. tPacketCapture for Android,
the exact model is BRAVIA KDL-50W829B
I noticed that changing the line with this one (I found on this http://mendelonline.be/sony/sony.txt):
cookie=$(curl --include --silent -XPOST http://$tv_ip/sony/accessControl --header "$tv_auth_header" -d "{\"id\":13,\"method\":\"actRegister\",\"version\":\"1.0\",\"params\":[{\"clientid\":\"$my_nick:$my_uuid\","nickname":\"$my_nick ($my_device)\"},[{\"clientid\":\"$my_nick:$my_uuid\",\"value\":\"yes\",\"nickname\":\"$my_nick ($my_device)\",\"function\":\"WOL\"}]]}")
is going to the next step but the output is:
Trying to register on 192.168.1.119, this time with the given code…
{"error":[5,"Illegal JSON"]}:20 GMT
If everything worked, you should see an auth=<code> line above.
Your computer is now registered, use it like this:
curl --cookie "HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 28
Connection: keep-alive
Date: Fri, 01 Jan 2016 20:14:20 GMT
{"error":[5,"Illegal JSON"]}" -XPOST http://192.168.1.119/sony/system -d '<JSON STUFF>'
Available IRCC commands have been saved to 'ircc_command_list'
Run a IRCC command with: ./send_command.sh 192.168.1.119 <IRCC-Code>
I really don't understand....
Can you please properly format you comments? Otherwise it's incredibly hard to see what’s going on.
As for the illegal JSON error: that's because, well, the data you are sending is invalid JSON. I think you are missing a backslashes for the double quotes around the "nickname":\"$my_nick
.
In any case debugging JSON like this is very painful -- the shell needs double quotes to evaluate the variables and JSON also requires double quotes, so all of them need to be escaped. You're probably better off to replace the variables manually and run it like this:
curl -v -XPOST http://$tv_ip/sony/accessControl --header "$tv_auth_header" -d '{"id":13,"method":"actRegister","version":"1.0","params":[{"clientid":"$my_nick:$my_uuid",nickname:"$my_nick ($my_device)"},[{"clientid":"$my_nick:$my_uuid","value":"yes","nickname":"$my_nick ($my_device)","function":"WOL"}]]}'
This is still pretty cumbersome, but I do not know any better way in shells. Maybe the following guides are helpful for you: http://wiki.bash-hackers.org/syntax/quoting https://jsonformatter.curiousconcept.com/ (section learn about json)
Also, as far as I can tell the line you found doesn’t change anything but the id from 8 to 13. The order is different, too, but that's not significant for JSON.
Sorry for the formatting, thanks for the links, I'll take a look and I'll keep you posted.
Maybe it's me but I cannot make it work. I tried this step getting all the correct data from the shell and the screen of my TV and I don't have any error from the shell but my television is answering me... remote request is cancelled.
curl --include --silent -XPOST http://192.168.1.119/sony/accessControl --header "Authorization: Basic OTM0MA==" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:5514F62F-46DD-4AC4-B985-D5E9C4C22987\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}" | grep -o -E 'auth_cookie=([a-z0-9]+)'
Everything seems right, so maybe its some weirdness in the tv software. Can you try to register with a lower case uuid?
You should be able to generate one using
uuidgen | tr '[A-Z]' '[a-z]'
On January 2, 2016 5:53:32 PM GMT+01:00, xuncia notifications@github.com wrote:
Maybe it's me but I cannot make it work. I tried this step getting all the correct data from the shell and the screen of my TV and I don't have any error from the shell but my television is answering me... remote request is cancelled.
curl --include --silent -XPOST http://192.168.1.119/sony/accessControl --header "Authorization: Basic OTM0MA==" -d "{\"method\":\"actRegister\",\"params\":[{\"clientid\":\"xun:5514F62F-46DD-4AC4-B985-D5E9C4C22987\",\"nickname\":\"xun (bravia)\",\"level\":\"private\"},[{\"value\":\"yes\",\"function\":\"WOL\"}]],\"id\":8,\"version\":\"1.0\"}" | grep -o -E 'auth_cookie=([a-z0-9]+)'
Reply to this email directly or view it on GitHub: https://github.com/breunigs/bravia-auth-and-remote/issues/4#issuecomment-168406859
I have the same problem, it works until the tv shows that the request is remotely canceled
The problem is here: $(echo -n ":$tv_challenge" | base64) which generates the string with "-n " if you decode it. change "echo -n" to "printf" solved my issue. I'm running on OS X.
@rbmjw you're right! OSX has a very basic implementation of echo. I changed the script to use a compatible approach to avoid the new line. Thank you for the hint!
@Tuxliri, @xuncia can you retry with the new version?
@breunigs there are a few more minor issues: "..." in line 29 and 49 seem to be translated into a single special character; also auth filtering in line 51 should include upper letter as well: "[A-Za-z0-9]+"
@rbmjw
regarding …
: it is one special character: https://en.wikipedia.org/wiki/Ellipsis#Computer_representations
regarding the auth filtering: for me the TV only ever returns lower case characters. Is this different for your model?
ah wait… did you mean that the OSX terminal is not capable of displaying "…" properly and instead displays some other symbol?
@breunigs on Mac, special character ... "eats" some of the late outputs.
Yes, my TV return cookie in upper letters.
All fixed. Thanks!
Yes now it works.
Nice to hear. Thanks again everybody for debugging this.
Hi, I was trying on OSX and the first script gives me:
It seems that the cookie is not created, and indeed after the second script
the print_icc , the result is :
Do you have any idea? I'm using a BRAVIA KDL 50W829B
thanks