我正在为whatsapp使用api,正在使用Yowsup。
当我使用Yowsup Cli客户端时,我设法登录到whatsapp帐户并从中发送和接收消息。
当我尝试使用以下脚本时,它返回“ 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)

最佳答案

问题是访问令牌需要更新。
在Yowsup包中的comon \ constans.py下
有必要将tokanData更新为:

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"
}


您可以看到我拥有的东西和需要使用的东西之间的区别

关于python - Yowsup身份验证失败whatsapp,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27621131/

10-12 14:19