bbernhard / signal-cli-rest-api

Dockerized Signal Messenger REST API
https://bbernhard.github.io/signal-cli-rest-api/
MIT License
1.3k stars 154 forks source link

Captcha error while registering a number #89

Closed jyothisjose closed 2 years ago

jyothisjose commented 3 years ago

On registering a phone number with signal, we are getting following error

{"error":"Captcha invalid or required for verification (null)\n"}.

We are using curl -X POST -H "Content-Type: application/json" 'https://127.0.0.1:8080/v1/register/v1/register/+PHONE_NUMBER_COUNTRY_CODE'

horizonchasers commented 3 years ago

I have this same issue currently. I installed it using Home Assistant and I also installed it on a dedicated container in my docker environment. Same response {"error":"Captcha invalid or required for verification (null)\n"}. both times.

bbernhard commented 3 years ago

I have this same issue currently. I installed it using Home Assistant and I also installed it on a dedicated container in my docker environment. Same response {"error":"Captcha invalid or required for verification (null)\n"}. both times.

Looks like that you need to provide a captcha (see details here: https://github.com/bbernhard/signal-cli-rest-api/issues/19)

Cempakers87 commented 3 years ago

That's true. You must provide captcha curl -X POST -H "Content-Type: application/json" --data '{"captcha": "<captcha>"}' 'http://127.0.0.1:8080/v1/register/+1234567890'

jyothisjose commented 3 years ago

We have used captcha from https://signalcaptchas.org/registration/generate.html and executed following command.

_curl -X POST -H "Content-Type: application/json" --data '{"captcha": "03AGdBq263LoI21mz7kUvZRp_WuzeIDjG-zo2v7QF_R4-GeJEYUtq1OqlKuBqNVONxe3-Kxt8E4v12TuiIkylLCzPBba6GUm-bpTqWVbfJ97ecjBg_52iZ9Q9XrOMBXdO0ORuFSL-vNS9Z57e9xM6RMXFxLTHEcJiXoROlVvnrw1TxX-punYMpivgy-naQrNE3LjmOj1vKgMiRtN1aNFEwSaJ_zPLcAX8sZtKfMpnjtq5Wr1rGp9DIBB0xGir7AyyfnFZmiGAW5TIfI5etMKmpg6V1or3ekF4Ft3lLEy77uyPuLD3wHd59FyfJAFFHFqnYJV5Y8jnU0jIY8C_LgzQImh6HqGIav8kNK6V1140XuGCdkLNASSgU8AFQtzrEGM2RW3tilxDm6vKlvHnI9r8Sc6O6iDSXbSqhX8bhPKSUxMGiekPFqAqmD3KyAjSoKCCOyzmiEvV1OIIwkZsehCvKu7P2nINBy4Tjw"}' 'http://127.0.0.1:8080/v1/register/+91xxxxxxx'

Still we are getting same error {"error":"Captcha invalid or required for verification (null)\n"}j

Can you please help us to solve registration issue?

Cempakers87 commented 3 years ago

@jyothisjose how many times have you tried your command above? just once or more? mentioned here https://github.com/bbernhard/signal-cli-rest-api/issues/19#issuecomment-772827785 that he tried 4-5 times. Hope that helps.

For me, I try with succes on my first time.

EJansenMSFT commented 3 years ago

This is the closest that I've been thus far:

I just don't know what syntax I'm messing up. Here's the latest Captcha:

image

Here's the latest attempt, which says that the captcha is invalid trying it with and without the //:

image

image

Thanks for any guidance that anyone has!

fanuch commented 3 years ago

I've been hopping around from project to project but I do not think any of them require signalcaptcha://

Try only the character after signalcaptcha:// that is "signalcaptcha://<this only>"

Make sure you are using a recent captcha too.

On mobile so I can check later in practice

EJansenMSFT commented 3 years ago

Awesome, I'll try it out in about an hour and post back. Thanks!

I've been hopping around from project to project but I do not think any of them require signalcaptcha://

Try only the character after signalcaptcha:// that is "signalcaptcha://"

Make sure you are using a recent captcha too.

On mobile so I can check later in practice

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/bbernhard/signal-cli-rest-api/issues/89#issuecomment-792381801, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARHXWQQQIXTWBVV7BWQHFI3TCQI3HANCNFSM4XOFHB2Q.

EJansenMSFT commented 3 years ago

Unfortunately, if I do it without the prefix, it fails with the following error:

image

In looking at the error on the container, it shows the following:

image

So it at least sees it as a key. I tried a few things after that, based on the error, but nothing seemed to work. Closer at least. Any suggestions?

Thanks, Eric

fanuch commented 3 years ago

That's true. You must provide captcha curl -X POST -H "Content-Type: application/json" --data '{"captcha": "<captcha>"}' 'http://127.0.0.1:8080/v1/register/+1234567890'

@EJansenMSFT mate... You didn't follow the JSON structure as per this....

The "value" in "key:value" pair is the captcha. You are missing "captcha": (literally)

Also, if you are using single quotes (') pretty sure you do not need to escape the double quotes (") i.e. don't so \"

But definitely wrong with out the key"captcha": before your captcha

EJansenMSFT commented 3 years ago

I had '{"captcha": ""}' a few posts up and I my understanding of what you said was to not use the key. I really don't know because yesterday was literally the first time I've ever used curl before. If I don't escape the double quotes, I get this error:

image

image

If you were to modify the following, what would you change?

curl -X POST -H "accept: application/json" -H "Content-Type: application/json" --data '{"captcha":"03AGdBq25uKao8EWXvnhILvYnRf4hGQPI7-FBdF8iIZ_ChgkesTMt2iuzqxgZHjEfv_gGerR6WlaWCQlep48Mforf-zB1NjTPR3KaSOejI0q5imeD0qkc-DuU6nLWqticD_orvyVvWBWWprevHGJ336gcqzjETBKM1xsvF6AnL3lrjVC0pbcgUX_ycwWUAZ4PB7yt2YJ-ZG53Ja6h5KA8oHNfZk2gED3WBtY1lOXcutVwrUA1VG24l-YooV3aM6hrzsARD9Iw6O7ciKaDUOo_Vy3YQOX6RsFnnRInT1Jz1L0PJcT3Nhu_kYKPdJN8rur_ivj5iezwwpkYM6llRd53XVC12uQwW7-F6vCllGep4R-7OI9FLSkjiEIj-kwbr1hve4a6CRXYPpbH6szdPd9Fe-UsLR-PilE1bpVcT0MheJipV5rW2lp42-6NzRdZ6ztPSgXIOrL_XEjyH5F9d8EOeWxpdw5RpbICBrA"}' 'http://127.0.0.1:8080/v1/register/+1...........'

Cheers, Eric

fanuch commented 3 years ago

@EJansenMSFT I copy and pasted what you have above with nothing more than my number and a new captcha and it worked.


It's making a bit more sense to me. You are on PowerShell making the request. I have to assume it is not as standard as *nix CuRL.

Recommendation for you to make this less error prone and more repeatable:

  1. Download Postman
  2. Click on "Import" on the top
  3. Click on "Raw text" at the top
  4. Paste in the following:
  5. curl -X POST -H "Content-Type: application/json" --data '{"captcha": "<captcha>"}' 'http://127.0.0.1:8080/v1/register/+1234567890'
  6. Click "Import" again to accept
  7. In the top bar, edit your number to replace the +1234567890
  8. Directly under that click the tab that says "Body"
  9. Go get a new Captcha from https://signalcaptchas.org/registration/generate.html
  10. Look at the Debug Tools (console) and copy <captcha> from "signalcaptcha://<captcha>" (do not copy the quotes or beginning of the URI!!)
  11. Paste it in to replace the <captcha> in the body {"captcha": "<captcha>"} (make sure you leave the double quotes!!!)
  12. Click "Send" in the top right
  13. If successful, you should see nothing returned and "Status 201 Created"
image
EJansenMSFT commented 3 years ago

Thanks for the detailed write up. Definitely appreciate you!

I tried it a few times, but it doesn't want to play nice. Here's the latest captcha and screenshots from Postman and the Container:

image

image

image

I'll keep playing with it.

Thanks again!

bbernhard commented 3 years ago

Do you see any output in Postman after executing the API call? Besides the 400 status code, there should also be an error message returned from the REST API. Something like {"error": "...."}

EJansenMSFT commented 3 years ago

Hmm, I tried it a few more time, and generated a new captcha, and now it worked. No further changes.

image

Have no idea why it all of the sudden worked.

EJansenMSFT commented 3 years ago

If the attempt fails using a captcha one time, should I have been generating a new captcha every single time? If so, maybe that's part of it.

bbernhard commented 3 years ago

If the attempt fails using a captcha one time, should I have been generating a new captcha every single time? If so, maybe that's part of it.

Creating a new captcha is definitely recommended!

I don't know the details about the captcha handling mechanism on the server side, but if I would implement something like this, I would probably set a pretty short expiration date to prevent abuse by scripts. So, one problem could have been that you just were too slow.

EJansenMSFT commented 3 years ago

Do you see any output in Postman after executing the API call? Besides the 400 status code, there should also be an error message returned from the REST API.

image

No errors that I could see in Postman or on the Container.

bbernhard commented 3 years ago

No errors that I could see in Postman or on the Container.

That's strange. I've checked again in the sourcecode: The error isn't logged (so you won't see it in the container log file), but should be reported back via the REST API. But as it has worked now for you, I guess it was just some error from the Signal Server telling you that the captcha was wrong.

EJansenMSFT commented 3 years ago

I did get a text message to my phone with the six digit pin, but the pin fails :(

How many times can I attempt to use the pin before I have to try to re-register my phone to get a new pin?

Is the syntax correct?

Thanks!

bbernhard commented 3 years ago

I did get a text message to my phone with the six digit pin, but the pin fails :(

How many times can I attempt to use the pin before I have to try to re-register my phone to get a new pin?

Is the syntax correct?

Thanks!

I've removed your screenshot, as you've accidentally leaked your phone number.

Are you sure that you need to set the pin? Or in other words: Are you using a new SIM card or was it already in use with Signal?

EJansenMSFT commented 3 years ago

Ah whoops, preciate that. Yeah the phone is already registered with Signal.

bbernhard commented 3 years ago

Yeah the phone is already registered with Signal.

Is the number still in use? Signal doesn't allow the number to be registered on multiple devices. So, if there's already a client (e.g your smartphone) using the number, you either have to use a dedicated SIM card for the REST API (personally I find that the better option) or link your device (there's a dedicated REST API endpoint for linking devices).

In case the number was previously used by another client, but is not anymore you are good to go.

EJansenMSFT commented 3 years ago

Yeah the number is still in use. Right now I'm just testing the functionality, so I'd have to go buy another sim. Hmm, so how can I register container / device? Essentially what I want to do is write PowerShell wrappers around everything so I can send secure notifications for something like a network outage etc.

bbernhard commented 3 years ago

Yeah the number is still in use. Right now I'm just testing the functionality, so I'd have to go buy another sim. Hmm, so how can I register container / device? Essentially what I want to do is write PowerShell wrappers around everything so I can send secure notifications for so mething like a network outage etc.

I do not have any experience with linking devices, so I most probably can't help you troubleshoot in case you are running into problems. But there are some people out there that have successfully linked their devices.

It basically works like this:

See also this thread here: https://github.com/bbernhard/signal-cli-rest-api/issues/35

EJansenMSFT commented 3 years ago

That goes back to my original issue, where though I can use curl, I can't actually connect using the browser for some reason:

image

EJansenMSFT commented 3 years ago

Disregard, got the curl equivalent working and it generated a QR code.

EJansenMSFT commented 3 years ago

Unfortunately when I try to link the device in Signal from my cell phone, it just gives a network error.

EJansenMSFT commented 3 years ago

I found another phone to use though that's not registered with Signal :)

poudenes commented 3 years ago

after last update I must reregister my number:

root@ha:/var/log# curl -X POST -H "Content-Type: application/json" 'http://127.0.0.1:8080/v1/register/+MY NUMBER'  
{"error":"Captcha required for verification, use --captcha CAPTCHA\nTo get the token, go to https://signalcaptchas.org/registration/generate.html\nCheck the developer tools (F12) console for a failed redirect to signalcaptcha://\nEverything after signalcaptcha:// is the captcha token.\n"}root@ha:/var/log#
root@ha:/var/log# curl -X POST -H "Content-Type: application/json" -d '{"captcha":"03AGdBq25HWvcvFF1FfyR8ukURWy94H73t1Y_Phwj54wPWpF5hCyK3LTaTSptn5r2c3obXWNXfGvCDCg5hZe6gssDURFaKtZlLYIb9OLoE6ifoD657mSUdpA0xw7cvKjgAd5-VnRL-fbkXHOW28Rypoc-9Q49QjxRL7AMPENTFRbj-TBBzKahfvlHu2WEphZPiUj3FW7tlGSTVn6JNHMC9_K5nFednZMHqdW72OzyHcE3gueMc_SiTinvUYrVVUtnRpX0Zj9_PRCiSRY-lyJjq41LeEXRldjtZIgNwLPySOOz8bQs15VVGAFhHS82Ry71ilrwdLurB2pP3WBwkEDFJiHZKZbOCIcrHZjSlKsZgtDmfrbYqAJJtFMrj8aPVPsqkKW6I56zUhvue2Qt2rsBSMI0_mznU8yjtX9To-wgPgfB3DrKlY46jfXvJ2DoRZz-qCD-y1wGwTfstTTBSRRZ_J0yjdEhcPyrEIA"}'  'http://127.0.0.1:8080/v1/register/+MY NUMBER'
root@ha:/var/log# 

No errors. But when I want send a message in log I see this:

2021-03-14 21:07:18 ERROR (SyncWorker_28) [homeassistant.components.signal_messenger.notify] ERROR App - User +MY NUMBER is not registered.

bbernhard commented 3 years ago

Have you verified the registration with the verification code you received via SMS?

poudenes commented 3 years ago

Have you verified the registration with the verification code you received via SMS?

ahh that was last part I forgot! Thanks

bbernhard commented 2 years ago

Should be fixed. Please re-open in case it's still an issue.