无法通过python API登录到Salesforce沙箱

时间:2019-04-11 16:39:34

标签: salesforce sandbox python-3.7 simple-salesforce

我正在使用python3.7.2模块simple-salesforce==0.74.2,尝试建立与我的salesforce沙箱的连接时遇到了麻烦。我可以使用相同的凭据登录到Salesforce生产,就像​​这样:

from simple_salesforce import Salesforce
sf = Salesforce(username='user@domain.com', password='pswd', security_token='mytoken')

好酷。现在,我尝试使用以下命令登录到沙箱:

sf = Salesforce(username='user@domain.com.sandbox_name', password='pswd', security_token='mytoken', sandbox=True)

我得到了错误:

  

simple_salesforce.exceptions.SalesforceAuthenticationFailed:   INVALID_LOGIN:无效的用户名,密码,安全令牌;或用户   锁定。

所以我尝试使用其他方法登录:

sf = Salesforce(username='user@domain.com.sandbox_name', password='pswd', security_token='mytoken', domain='sandbox_name')

这给出了另一个错误:

  

requests.exceptions.ConnectionError:   HTTPSConnectionPool(host ='sandbox_name.salesforce.com',port = 443):最大值   网址超出了重试次数:/services/Soap/u/38.0(由   NewConnectionError(':无法建立新的连接:[Errno 8]   提供的节点名或服务名,或者未知')

我正在按照Salesforce的说明使用名为sandbox_name的开发人员沙箱。有人可以针对我的不正确行为提供一些建议吗?

3 个答案:

答案 0 :(得分:0)

已解决。设置domain='test'并在您的沙盒帐户下生成一个新令牌

答案 1 :(得分:0)

这对我不起作用,但实际上是:

TypeError at /boards/1/

object of type 'Board' has no len()

Request Method:     GET
Request URL:    http://127.0.0.1:8000/boards/1/?page=1
Django Version:     2.2.3
Exception Type:     TypeError
Exception Value:    

object of type 'Board' has no len()

答案 2 :(得分:0)

此处的建议可能已过时。进行了一些修补之后,我可以使用以下代码在自定义域上与Salesforce沙箱一起使用simple_salesforce库。请注意我要传递给api的域以及需要附加到用户名后的sand_box名称。

  | "my_function x b (Cons3 y) = (if x=y then b else (Cons3 y) )"