我按照教程向Salesforce发送访问令牌请求。但我不知道如何得到答复。我的代码如下:
String baseUrl = "https://login.salesforce.com/services/oauth2/token";
PostMethod method = new PostMethod(baseUrl);
HttpMethodParams params = new HttpMethodParams();
StringBuilder content = new StringBuilder();
content.append("grant_type=password");
content.append("&client_id=3MVG9Y6d_Btp4xp7iNInduj8sD72efFl1ge.T8VS9JGJGrWqlNQt2mdP5qFzUdIay56PHFWSO65aFnYLhpTS_");
content.append("&client_secret=4522939082487299040");
content.append("&username=vuong.tran@enclave.vn");
content.append("&password=vuong92dnKk2VykEJnVfj5Dps0as9XmRFV");
method.setRequestEntity(new StringRequestEntity(content.toString(), "text/plain", "UTF-8"));
method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
HttpClient client = new HttpClient();
client.executeMethod(method);
请帮忙。
答案 0 :(得分:1)
执行
后client.executeMethod(method);
您可以从作为参数传递的PostMethod
对象获取响应,例如:
String response = method.getResponseBodyAsString();
可以找到文档here。