【发布时间】:2020-01-30 01:06:23
【问题描述】:
我过得很糟糕......我正在尝试通过coldfusion从salesforce那里获得一个令牌,但我遇到了以下错误
{"error":"invalid_grant","error_description":"authentication failure"}
我试过 cfscript
local.http = new Http(url='https://test.salesforce.com/services/oauth2/token',method='post');
local.http.addParam(type='header',name='content-type', value='application/x-www-form-urlencoded');
local.http.addParam(type='formField',name='grant_type', value='password');
local.http.addParam(type='formField',name='client_id', value='client_id');
local.http.addParam(type='formField',name='client_secret', value='client_password_string');
local.http.addParam(type='formField',name='username', value='user@email.com');
local.http.addParam(type='formField',name='password', value='userspassword');
local.http.addParam(type='formField',name='format', value='json');
local.httpSendResult = local.http.send();
rc.httpResult = httpSendResult.getPrefix();
我试过 cfhttp 标签
<cfhttp url="https://test.salesforce.com/services/oauth2/token" method="POST">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded" />
<cfhttpparam type="formField" name="grant_type" value="password" />
<cfhttpparam type="formField" name="client_id" value="client_id" />
<cfhttpparam type="formField" name="client_secret" value="client_password_string" />
<cfhttpparam type="formField" name="username" value="user@email.com" />
<cfhttpparam type="formField" name="password" value="userspassword" />
</cfhttp>
<cfset rc.result = cfhttp.fileContent />
但是 cUrl 在我的本地机器上执行的完全相同的调用工作得非常好
curl -d "grant_type=password"
-d "client_id=client_id"
-d "client_secret=client_secret_string"
-d "username=user@email.com.dev"
-d "password=userpassword" https://test.salesforce.com/services/oauth2/token
我确保我的 ip 范围被列入白名单,我的 ip 放宽设置为放宽,所有用户都可以自行授权,我尝试了不同的用户名和密码参数,我得到的只是关于无效授权的相同错误
非常感谢任何帮助
【问题讨论】:
-
cUrl 代码是用于发帖还是获取?
-
@DanBracuk 我认为它必须是一个帖子,我认为您不能将令牌请求作为获取
标签: coldfusion salesforce