【发布时间】:2012-09-29 10:42:28
【问题描述】:
我正在尝试使用 OAuth 身份验证来获取 Salesforce 身份验证令牌,所以我引用了wiki docs,但是在获得授权代码后,当我使用 5 个必需参数发出 Post 请求时,我得到了以下异常
{"error":"invalid_grant","error_description":"authentication failure"} CODE 400
JSON = {"error":"invalid_grant","error_description":"authentication failure"}
我猜这是一个错误的请求。
PostMethod post = new PostMethod("https://login.salesforce.com/services/oauth2/token");
post.addParameter("code",##############);
post.addParameter("grant_type","authorization_code");
post.addParameter("redirect_uri","#################");
post.addParameter("client_id",this.client_id);
post.addParameter("client_secret",this.client_secret);
httpclient.executeMethod(post);
String responseBody = post.getResponseBodyAsString();
System.out.println(responseBody+" CODE "+post.getStatusCode());
如果已知异常,请回复?
【问题讨论】:
-
您找到解决方案了吗?我也面临同样的问题。
-
Salesforce 仅允许我们使用有效的电子邮件域,即不允许 yopmail.com、mailinator.com 等测试域。是允许的。
-
你是怎么得到代码的
-
检查您的 IP 范围。然后转到您的姓名 --> 我的设置 --> 个人 --> 重置我的安全令牌。您必须将该令牌附加到密码,例如:密码+令牌。试试看!
标签: salesforce oauth-2.0 force.com