pairing with -0 parameter STDIN not working anymore
Is there an existing issue for this?
- [x] I have searched the existing issues
Is your issue described in the documentation?
- [x] I have read the documentation
Is your issue present in the latest beta/pre-release?
None
Describe the Bug
i changed the code here to have a fixed pin for an automated pairing workflow - like std::string pin = "1234"; https://github.com/LizardByte/Sunshine/blob/7b873e9ea42d542312576818c6fb1a03e04ae156/src/nvhttp.cpp#L582
In earlier releases like 0.23.1 this pairing process worked fine but in the latest code it seems something has changed.
i also found this code and here you need a pin and a name and in earlier releases you only had a pin there and no name https://github.com/LizardByte/Sunshine/blob/7b873e9ea42d542312576818c6fb1a03e04ae156/src/confighttp.cpp#L1022C7-L1023C59
so what should be changed here so that stdin will work again? (moonlight only passes a pin and can't pass a name)
Expected Behavior
No response
Additional Context
No response
Host Operating System
Windows
Operating System Version
Win 11
Architecture
amd64/x86_64
Sunshine commit or version
master branch
Package
Windows - portable (not recommended)
GPU Type
AMD
GPU Model
RTX 3070
GPU Driver/Mesa Version
latest
Capture Method
None
Config
Apps
Relevant log output
nothing
The name is provided in web UI / rest API.
What moonlight client and version are you using? My suspicion is this actually broke from fixing out of order pairing: https://github.com/LizardByte/Sunshine/security/advisories/GHSA-3hrw-xv8h-9499
If it's an official client and updated, then perhaps this (https://github.com/LizardByte/Sunshine/blob/7b873e9ea42d542312576818c6fb1a03e04ae156/src/nvhttp.cpp#L581-L588) should have been updated with https://github.com/LizardByte/Sunshine/pull/2042
Not sure we should even support this feature through stdin anymore though. That's a legacy thing from before the web UI existed.
please let this feature with stdin in the code because i need it for an automated way to do the pairing process. i used moonlight version 6.0.1 on a windows 7 machine but normally i use moonlight 6.1.0 on win 11 or win 10. probably i should try it with moonlight 6.1.0 once again. but would it also possible to pair with a curl command on the api endpoint of the webserver? if this is possible i would send a post request with pin and name to that endpoint. and @xanderfrangos should give answer if this influences the stdin code.
i just tested it with moonlight v6.1.0 on win 10 but this didn't help. so it seems that the changes from using pin and name are corrupting getservercert(ptr->second, tree, pin); somehow. please have a look and try to fix it. thank you.
the last sunshine version i have compiled was 2024.922.10353 where the stdin was working fine. so something has changed probably since sunshine version 2025 reagrding this issue.
the last sunshine version i have compiled was 2024.922.10353 where the stdin was working fine
If that's the case then it has nothing to do with #2042 as this feature was already merged at that point.
i just tried it again with portable version v2025.509.184504 and when setting sunshine.exe -0 and after entering pin moonlight shows the error message Invalid uniqueid (Error 400) - probably here is something conflicting with stdin code: https://github.com/LizardByte/Sunshine/blob/7b873e9ea42d542312576818c6fb1a03e04ae156/src/nvhttp.cpp#L607
so if someone can look at this issue please.
another option i found for autopairing is to use the api endpoint sending a post request with pin and name. that i already have done now instead and it worked fine.
Seeing the same behavior - when pairing with a PIN via -0, I always get Invalid uniqueid (Error 400) from moonlight.
instead, you can do it with an curl request to the api endpoint. you have to study a little bit the code if you wish to have an automated pairing process.
Rest api works, we should still get it working through stdin or drop that option.
(For what it's worth, my use case wasn't in automating pairing, it was in setting up Sunshine on a single personal remote host where I didn't have physical access to use the monitor. I assume that's a pretty rare workflow all things considered, but figure it merits mentioning since the stdin flag (or anything similar) does work well for the once-off case.)
Went and looked it up - for future people also finding this thread on Google and trying to figure out how to input a sunshine pin from the command line, there's a curl command listed here that should do it: https://docs.lizardbyte.dev/projects/sunshine/latest/md_docs_2api.html#post-apipin
I believe there's supposed to be a return after the getservercert here:
https://github.com/LizardByte/Sunshine/blob/2f7657a1b0467c09defc7d092354ccf0057a0419/src/nvhttp.cpp#L586-L589
Otherwise, the code falls through but uniqID has been moved out so the "empty" uniqID fails to be found here:
https://github.com/LizardByte/Sunshine/blob/2f7657a1b0467c09defc7d092354ccf0057a0419/src/nvhttp.cpp#L605
Same problem
I don't have the exact command handy on this computer, but I think it looks something like this on Linux, the wiki I linked above has other methods:
SUNSHINE_USER=your_sunshine_username
SUNSHINE_PASSWORD=your_sunshine_password
# If you haven't set the username and password already:
sunshine --creds "$SUNSHINE_USER" "$SUNSHINE_PASSWORD"
# Once you have the pairing request from Moonlight:
DESIRED_PIN=your_pairing_pin_code
curl -u "$SUNSHINE_USER":"$SUNSHINE_PASSWORD" -H "Content-Type: application/json" -X POST -k https://localhost:47990/api/pin -d '{"pin":"'"$DESIRED_PIN"'", "name":"whateverhostname_doesnotmatter_afaik"}'
You can also run that curl command from anywhere that has network access (including the port being open) to the box running Sunshine.