tgalal / yowsup

The WhatsApp lib
GNU General Public License v3.0
7.06k stars 2.23k forks source link

not-authorized error after months working correctly #191

Closed stenyak closed 9 years ago

stenyak commented 10 years ago

Hello, I use yowsup as backend for a whatsapp<->IRC gateway bot ( https://github.com/stenyak/breakbot ). I've been succesfully using yowsup for a year without any major problems.

A few hours ago, the whatsapp user (the bot) got kicked out of all whatsapp groups, and I've verified that I can no longer authorize:

$ python yowsup-cli -c config.txt -l -d
[...]
YowsupAuth:     Connecting to c2.whatsapp.net
WAuth:  Yowsup WAUTH-1 INIT
[...]
BinTreeNodeReader:      Incoming
BinTreeNodeReader:      
<failure xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<not-authorized>
</not-authorized>
</failure>
[...]
Auth Failed!

This has happened over the night, without me changing anything in the yowsup connection configuration (or anything at all).

I understand this is very probably a problem with whatsapp services, and not with yowsup itself, but I wonder.. Has anyone else also got kicked out of whatsapp groups and unable to authenticate using yowsup?

Thanks for any help.

tgalal commented 10 years ago

First time I see this behavior, that's interesting. When was the last time you registered that number? I'm thinking it could be due to sending and old resource at login for too long? (You can see the resource in constants.py, or in ~/.yowsup/t if it updated itself, b64 encoded though).

Another possible reason would be because whatsapp sometimes sends a "Change password" message with a new password that clients should use in subsequent logins. Yowsup currently ignores the message and doesn't ack it, so maybe if the server sends this too many times and doesn't get a response, then it reacts in the way you've described? I've seen the change pw many times before, but it never caused problems though so still not sure..

stenyak commented 10 years ago

Now that you bring it up, it's interesting to note that I think I registered the bot around this exact time last year. I don't know the exact day, but mid-november I had already started to play with the current bot whatsapp account.

Could this maybe be the 1-year trial since first registration or something like that? I honestly can't recall if I've ever purchased whatsapp for my personal account or not. Not sure how to check that with the bot's fake phone number.

Regarding the "change password" message possibility, I personally have never seen it, and I have yowsup "debug" output disabled so I can't tell what happened last night.

Regarding the ~/.yowsup directory, I have no such dir in my home, nor in the bot working directory. Should I have one somewhere? For the record, I do all the auth programmatically, passing user/password via code parameters, and not using yowsup configuration file (like yowsup-cli does). I don't know what the "old resource" is about, can you explain so that I can check that too?

Let me know if I can generate more useful logs for your to try to analyze. Thanks for your time!

tgalal commented 10 years ago

oh then that might explain it. Try use yowsup-cli with -e, should output expiration date and new password, you have to use exact configuration you used at registration for this to work though. If doesn't work then try register again, will also output expiration date.

Don't worry about the ~/.yowsup dir, it's only there when the registration token expires.

As for the resource, if you have latest Yowsup then no need to worry about it. You don't also have a 1 year old yowsup, do you ?

stenyak commented 10 years ago

Regarding yowsup version, I forked in march 10th, when I was experiencing all those old encoding/decoding problems, in order to do quick-and-dirty bugfixes myself, for the time being. I haven't got around to merging your fixes and my fixes. However, for debugging this issue, I'm switching back to your branch at latest commit 8974ce230642087dadae5f89be44b9422aac5568 .

I had already tried the -e command, and I don't see anything regarding expiration date? Maybe I'm doing something wrong, this is the output:

$ python yowsup-cli -c config.txt -d -e
{'Accept': 'text/json', 'User-Agent': 'WhatsApp/2.11.1 S40Version/14.26 Device/Nokia302'}
cc=34&in=668878125&id=d41d8cd98f00b204e9800998ecf8427e
Opening connection to v.whatsapp.net
Sending GET request to /v2/exist?cc=34&in=668878125&id=d41d8cd98f00b204e9800998ecf8427e
WAExistsRequest:    {"status":"fail","reason":"incorrect","sms_length":6,"voice_length":6}

status: fail
sms_length: 6
reason: incorrect
voice_length: 6
tgalal commented 10 years ago

it's failing, you have to register again, you will see the expiration when you complete registration

stenyak commented 10 years ago

I can no longer access sms/voice for that phone number, so I cannot continue debuggin the problem for now. I'll see if I can think of something...

CODeRUS commented 10 years ago

for exists you should use same identity you used for registration. you should remember it or get from 1year logs :)