AsamK / signal-cli

signal-cli provides an unofficial commandline, JSON-RPC and dbus interface for the Signal messenger.
GNU General Public License v3.0
3.17k stars 301 forks source link

Add device link failed, Invalid device link uri #908

Closed code-IM-perfect closed 2 years ago

code-IM-perfect commented 2 years ago

Hi, Sorry for disturbing you but

.\signal-cli -u PhoneNumber addDevice --uri "sgnl://linkdevice?uuid=************&pub_key=****************"

gives me

INFO  AccountHelper - The Signal protocol expects that incoming messages are regularly received.
ERROR AddDeviceCommand - Add device link failed
org.asamk.signal.manager.api.InvalidDeviceLinkException: Invalid device link uri
        at org.asamk.signal.manager.DeviceLinkInfo.parseDeviceLinkUri(DeviceLinkInfo.java:30)
        at org.asamk.signal.manager.ManagerImpl.addDeviceLink(ManagerImpl.java:306)
        at org.asamk.signal.commands.AddDeviceCommand.handleCommand(AddDeviceCommand.java:48)
        at org.asamk.signal.App.handleLocalCommand(App.java:273)
        at org.asamk.signal.App.init(App.java:213)
        at org.asamk.signal.Main.main(Main.java:58)
Add device link failed.
'pub_key' is not recognized as an internal or external command,
operable program or batch file.

This was the exact URL I got from the bar code.

code-IM-perfect commented 2 years ago

NVM, I think it was something with PowerShell, using CMD there were no errors

sparrowme commented 1 year ago

Same error... different reason... :shrug: Illegal base 64 character. NOTE: This uri is the one generated from SignalDesktop

I thought maybe it was the dash (-) The dash DID get generated by SignalDesktop so maybe not an encoding issue on the cli. @AsamK Am I correct? Does that the character 20 referred to in the error is in the uuid?

signal-cli -u PHONENUMBER addDevice --uri "sgnl://linkdevice?uuid=xxxxxxxxxxxxxxxxxxx-xx&pub_key=xxxxxx"      
ERROR AddDeviceCommand - Add device link failed
org.asamk.signal.manager.api.InvalidDeviceLinkException: Invalid device link uri
        at org.asamk.signal.manager.api.DeviceLinkUrl.parseDeviceLinkUri(DeviceLinkUrl.java:36)
        at org.asamk.signal.commands.AddDeviceCommand.handleCommand(AddDeviceCommand.java:49)
        at org.asamk.signal.App.handleLocalCommand(App.java:289)
        at org.asamk.signal.App.init(App.java:229)
        at org.asamk.signal.Main.main(Main.java:60)
Caused by: java.lang.IllegalArgumentException: Illegal base64 character 20
        at java.base/java.util.Base64$Decoder.decode0(Base64.java:848)
        at java.base/java.util.Base64$Decoder.decode(Base64.java:566)
        at java.base/java.util.Base64$Decoder.decode(Base64.java:589)
        at org.asamk.signal.manager.api.DeviceLinkUrl.parseDeviceLinkUri(DeviceLinkUrl.java:34)
        ... 4 common frames omitted
Add device link failed.
sparrowme commented 1 year ago

Apparently a newly generated code causes me the same error. It does not have a dash.

This is also running inside an alpine docker container.

I thought the default ash shell was the issue, but changing to bash did not fix it.

AsamK commented 1 year ago

According to the stack trace, the character 20 referes to the pub_key value.

sparrowme commented 1 year ago

Thanks for the clarification @AsamK .
Does that mean the pub_key sent is somehow being mangled by bash? Does some other encoding need to happen? Or perhaps my method (below) is causing an issue. All other commands - device registration, captcha and usage seems to be working as intended.

Here is how I am getting the code to the CLI.. .perhaps you see a step here that is creating some invalid characters.

I echo the link to the screen during container load to compare it and it "looks" the same :shrug:

sparrowme commented 1 year ago

With a bit more exploration, I've discovered that generating several different QR codes from the desktop client (by choosing Preferences->Privacy->Clear data) will eventually generate a sgnl:// link that will be accepted by the cli. This was successful on two different accounts one needed about 8 different attempts to work and then next about 15. All failed links resulted in the error detailed above ...

Illegal base64 character 20

doxygen-spammer commented 2 months ago

Just a note for future users having this error message:

Pay attention to the quotes around the URI. In my case, using single quotes (I am using bash) fixed the trouble.

BTW Thank you for providing signal-cli! :)