Yowsup auth fail whatsapp

1.9k views Asked by At

i am working on an api for whatsapp, i am using Yowsup. when i use Yowsup Cli client i manage to login to the whatsapp account and send and receive messages from it. when i try to use the following script, it return "Auth Failed!".

import sys
import os
import logging
import time
import shutil
import Queue
from collections import defaultdict

from Yowsup.Common.debugger import Debugger
from Yowsup.connectionmanager import YowsupConnectionManager

from py_utils import logutils
from py_utils import executable_utils
from py_utils import exception_utils

from py_utils.cli_utils import actions_handler


COUNTRY_CODE = "COUNTRY_NUM"
PHONE_NUMBER = "MYNUMBER"
# IDENTITY = ""
PASSWORD = 'MY_PASS_WORD'
LOGIN = COUNTRY_CODE + PHONE_NUMBER

import argparse, sys, os, csv
from Yowsup.Common.utilities import Utilities
from Yowsup.Common.debugger import Debugger
from Yowsup.Common.constants import Constants
from Yowsup.Contacts.contacts import WAContactsSyncRequest
from Yowsup.connectionmanager import YowsupConnectionManager

import threading,time, base64

########## DO NOT COMMIT THIS FILE WITH YOUR CREDENTIALS ###########
#.....................WhatsApp Account Config.......................

nickname = "lamaaaaaaa"
username = LOGIN
password = PASSWORD

id = "" # Not required

#....................................................................

# Degug is False by default if you add -d you will set it to True
Debugger.enabled = True if '-d' in sys.argv else False
password = base64.b64decode(bytes(password.encode('utf-8')))

def login(username, password):
    print "[] Logging in as %s (%s)\n" % (nickname, username)
    methodsInterface.call("auth_login", (username, password))

def onAuthSuccess(username):
    print("Authed!!\n\n")
    methodsInterface.call("ready")
    methodsInterface.call("presence_sendAvailableForChat", (nickname,))

def onAuthFailed(username, err):
    print("Auth Failed!")

########################### BIND EVENTS #############################
connectionManager = YowsupConnectionManager()
signalsInterface = connectionManager.getSignalsInterface()
methodsInterface = connectionManager.getMethodsInterface()
connectionManager.setAutoPong(True)

signalsInterface.registerListener("auth_success", onAuthSuccess)
signalsInterface.registerListener("auth_fail", onAuthFailed)
#####################################################################

login(username, password)    
1

There are 1 answers

2
Omega Doe On BEST ANSWER

The problem is the the access token need to be update. in the Yowsup package there under comon \ constans.py there a need to update the tokanData to :

tokenData = {
    "v": "2.12.53",
    "r": "S40-2.12.53",
    "u": "WhatsApp/2.12.53 S40Version/14.26 Device/Nokia302",
    "t": "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1416435341393{phone}",
    "d": "Nokia302"

    # "v": "2.12.15",
    # "r": "S40-2.12.15",
    # "u": "WhatsApp/2.12.15 S40Version/14.26 Device/Nokia302",
    # "t": "PdA2DJyKoUrwLw1Bg6EIhzh502dF9noR9uFCllGk1391039105258{phone}",
    # "d": "Nokia302"
}

you can see the difference between what i had and what i need to use