尝试连接到 vTiger 时凭据无效

Invalid credentials when trying to connect to vTiger

我正在尝试使用 python

通过 vtiger CRM5 中的网络服务登录

将我的密钥和用户名放入params 时,我只得到一个INVALID_AUTH_TOKEN,但将它放入body 时,我得到INVALID_USER_CREDENTIALS。哪个看起来更好但不太有效!

{'success':假,'error':{'code':'INVALID_USER_CREDENTIALS','message':'Invalid username or password'}}

# -*- coding: utf-8 -*-

import json
import requests
from hashlib import md5
from requests.auth import HTTPBasicAuth

api_url_base = 'http://crmaddress/webservice.php'
username = 'myusername'
accessKey = 'fghdhgfhfdhgfd'
headers =  {"ContentType":"application/x-www-form-urlencoded"}

response = requests.get(api_url_base,params={"operation":"getChallenge","username":username})
token =  json.loads(response.content.decode('utf-8'))['result']['token']

key = md5(accessKey.encode('utf-8')+token.encode('utf-8')).hexdigest()
print(key)

response = requests.post(api_url_base,data={"operation":"login","accessKey":key,"username":username,},auth=HTTPBasicAuth('myusername','mypassword'),headers=headers)
print(json.loads(response.content.decode('utf-8')))

没有 运行 代码我无法验证,但问题似乎出在某个地方

key = md5(accessKey.encode('utf-8')+token.encode('utf-8')).hexdigest()

此外,我建议创建一个包装器 class,而不是直接使用网络服务。请查看我在 github 上写的 python3 wrapper。让我知道这是否有帮助。