I had no luck with @Jozef's answer, because I could only find Linux builds of Chromium, not Chrome, and Chromium seems to never have implemented chrome://cast
.
However, I did find some documentation of the Chromecast's API at https://rithvikvibhu.github.io/GHLocalApi/, and I noted that if you're doing initial setup, none of it needs any authentication. There was also some useful information at https://github.com/rithvikvibhu/GHLocalApi/issues/68#issue-766300901 about how you need to encrypt the WiFi password with a public key from the device before submitting it.
So, I put together a Bash script, which I've published at https://gist.github.com/interfect/5f68381d55658d334e2bc4619d796476, which can do the Chromecast initial setup and connect it to WiFi without Google Home or an Android or iOS device. All you need is a Linux or (probably) Mac environment, or (probably) WSL on Windows.
To use it, you need to get your computer on the same network as the Chromecast somehow, either with an Ethernet adapter for the Chromecast (which I tested) or by somehow finding and joining its setup hotspot (which I have not tested).
If you're a big fan of the curl | bash
school of system administration, you can:
wget https://gist.githubusercontent.com/interfect/5f68381d55658d334e2bc4619d796476/raw/1d16ead908a92742d5f22231a2611242d673654f/castanet.sh
chmod +x castanet.sh
CHROMECAST_IP=192.168.0.100 WIFI_SSID="foobar" WIFI_PASSWORD="hackme" ./castanet.sh
I don't want to copy-paste a whole script in here, since I don't think that's what StackExchange is for, but the important steps are:
- Get the device RSA
public_key
from the JSON available via TSL 1.2 HTTPS to port 8443 at /setup/get_eureka_info
. (My curl
defaulted to 1.3, and that was too new for the device and I had to dissuade it.)
- POST to
/setup/scan_wifi
- After a bit, get
/setup/scan_results
, find your network, and grab the wpa_auth
(always 7?) and wpa_cipher
(always 4?)
- Encrypt the password to the device's public key using
RSA_PKCS1_PADDING
and an oaepHash
of sha256
(the nodejs crypto
module can do this, if you wrap the key in BEGIN and END lines), and base64 encode the cyphertext.
- JSON post the
ssid
, wpa_auth
, wpa_cipher
, and enc_passwd
to /setup/connect_wifi
.
- JSON post a flag
keep_hotspot_until_connected
with value true true
to /setup/save_wifi
before the Chromecast decided to drop off the new wifi network.