go-chromecast icon indicating copy to clipboard operation
go-chromecast copied to clipboard

Reboot Chromecast Device

Open testcu opened this issue 3 years ago • 9 comments

It would be nice to be able to force a Chromecast Device to reboot (not by power off/on).

The following command should work, but needs the current ‘cast-local-authorization-token’ header / value. curl -Lv -k -H Content-Type:application/json https://192.168.5.74:8443/setup/reboot -d "{""params"":""now""}"

If you have the Auth Token available, would you please add the Reset Device Function?

Thank you!

testcu avatar Mar 16 '22 18:03 testcu

This would be a cool feature. I don't think we currently have a way to talk to that API, we currently talk to the api on port :8009 (default port). Would be happy to add this if we can work out a way to get the auth token, do you know a good way to retrieve it?

vishen avatar Mar 16 '22 20:03 vishen

Hello,

Thank you so much for the quick reply. I started down the path to get the auth token, but with my limited tool set- it was a manual process and the token expires.

Here are links to the references to get the token.

https://rithvikvibhu.github.io/gh-web-proto-decode/

https://github.com/rithvikvibhu/GHLocalApi/issues/39#issuecomment-643587959

https://gist.github.com/rithvikvibhu/952f83ea656c6782fbd0f1645059055d

https://github.com/leikoilja/glocaltokens

If you need any additional research I will we glad to help – just say what you need.

Thank you,

John

From: Jonathan Pentecost @.*** Sent: Wed, Mar 16, 2022 1:44 PM To: vishen/go-chromecast Cc: testcu; Author Subject: Re: [vishen/go-chromecast] Reboot Chromecast Device (Issue #131)

This would be a cool feature. I don't think we currently have a way to talk to that API, we currently talk to the api on port :8009 (default port). Would be happy to add this if we can work out a way to get the auth token, do you know a good way to retrieve it?

— Reply to this email directly, view it on GitHub https://github.com/vishen/go-chromecast/issues/131#issuecomment-1069613030 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AJUPWFSIAQRBE6ICM2FEGHDVAJBXVANCNFSM5Q4VYO5A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AJUPWFU7VFPBTKM4MHCDQN3VAJBXVA5CNFSM5Q4VYO5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOH7AP7ZQ.gif Message ID: @.***>

testcu avatar Mar 16 '22 21:03 testcu

I started down the path to get the auth token, but with my limited tool set- it was a manual process and the token expires.

How were you able to get the auth token? I am a little unsure how to get the auth token, and those code-snippets tend to want a username + password, are these a default username + password or is this something different for each chromecast?

vishen avatar Mar 18 '22 00:03 vishen

I used the User/Password from the device. To verify what it was, I used the Google Home App.

https://support.google.com/googlenest/answer/7552680?hl=en

Then used the manual process (phython3 https://github.com/leikoilja/glocaltokens) to get the token.

testcu avatar Mar 18 '22 17:03 testcu

Thanks! I'll have a look when I get a chance :)

vishen avatar Mar 18 '22 20:03 vishen

It doesn't look as simple as I was hoping. Looks like we need to get an auth token from the Google play store (maybe?) and then use that when making requests. Not sure how easy this will be, but here is some Go code that has done something similar (don't know if they still work):

  • https://github.com/dainis/go-playstore/blob/a79271e88c44fc168fe9c1ee95e0330a3bd96b65/const.go#L4
  • https://github.com/neuegram/Ghost/blob/1825110ea4ffbba3c5f2b032e715eff4d80b6889/ghost.go#L541
  • https://github.com/pogodevorg/pgoapi-go/blob/e8f4e09bf2a3ae15954adf742be95acf1f3cea67/auth/google/provider.go#L79
  • https://github.com/mjibson/gpsoauth/blob/be41f43784ed68405d473a38b886a4198aaf45b6/gpsoauth.go#L20

And here is some other useful info:

  • https://github.com/simon-weber/gpsoauth/blob/master/gpsoauth/init.py
  • https://github.com/rithvikvibhu/GHLocalApi/issues/39#issuecomment-644959103
  • https://rithvikvibhu.github.io/GHLocalApi

vishen avatar Mar 19 '22 21:03 vishen

I've 'been looking for ways to control my 1st gen Chromecast via command line and just stumbled across your project. Very impressive! You have created the most robust command set I've seen yet in a Chromecast CLI!

Here's my little contribution... You can reboot a chromecast through a simple http request: curl -Lv -H Content-Type:application/json http://192.168.22.99:8008/setup/reboot -d "{""params"":""now""}"

Don't fell bad. Many times, when you get very involved with a project, you naturally start making more and more complex functions. It's very easy to miss simple solutions once in a while after creating such a large application. That's why it's always a great idea to get a fresh set of eyes on the project once in a while. New blood can bring new perspectives and many times find a completely different way to accomplish something.

Anyway, that's my $0.02 worth of advice. I hope to provide some more assistance as I have time, and will fork the project at some point in the future to help with issues and new functionss.

Thank you for all your hard work and creating such a wonder Chromecast CLI!

Cyber5imon avatar Aug 27 '23 03:08 Cyber5imon

This may also come in handy. To do a factory reset use; curl -Lv -H Content-Type: application/json http://192.168.22.99:8008/setup/reboot -d ‘{“params”:”fdr”}’ -X POST

Cyber5imon avatar Aug 27 '23 05:08 Cyber5imon