我正在尝试使用带有companyId
和accountPassword
变量的auth
发送请求后身份验证,但如果使用auth
方式,则无法进行身份验证
下面的工作,但我不能使用URL中的用户名和密码作为其创建的用户名和密码存储在日志中的安全问题
url = AUTH_URI + '/' + dyn_url + "?appIdKey=" + str.encode(APP_ID_KEY) + "&companyId=" + self._user + "&accountPassword=" + self._pswd
r2 = requests.post(url,timeout=DEFAULT_REQUESTS_TIMEOUT,headers={'Content-Type': 'application/json;charset=UTF-8'},allow_redirects=False)
将其更改为使用auth变量无法进行身份验证,有关如何修复此问题的任何指导
url = AUTH_URI + '/' + dyn_url + "?appIdKey=" + str.encode(APP_ID_KEY)
r2 = requests.post(url,timeout=DEFAULT_REQUESTS_TIMEOUT,headers={'Content-Type': 'application/json;charset=UTF-8'},auth=('companyId=self._user','accountPassword=self._pswd'),allow_redirects=False)
我得到以下错误,不知何故'companyId=self._user','accountPassword=self._pswd'
没有生效
错误:-
Please enter the username and password
您正在发送字符串literal
'self._user'
作为用户名。如果正在运行Python 3.6或更高版本,请尝试使用f-strings:编辑:对于Python 2.7,它将是:
相关问题 更多 >
编程相关推荐