我試圖使用OAuth的CX公開的API,我也跟着他們的文檔,還是我越來越HTTP「錯誤的請求」的錯誤,這裏是代碼 -的Oauth不工作CX API
String method = "POST";
String code = "";
NameValuePair[] data = {
new NameValuePair("grant_type", "authorization_code"),
new NameValuePair("code", code),
new NameValuePair("redirect_uri",URLEncoder.encode(CALLBACK_URL, "UTF-8"))
};
String secret = CONSUMER_KEY+":"+CONSUMER_SECRET;
String encodedSecret = Base64.encodeBase64String(secret.getBytes("UTF-8"));
org.apache.commons.httpclient.HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
PostMethod httpMethod = new PostMethod(ACCESS_TOKEN_ENDPOINT_URL);
httpMethod.addRequestHeader("Authorization","Basic "+encodedSecret);
httpMethod.setRequestBody(data);
System.out.println("HTTP call -- " + method + " " + ACCESS_TOKEN_ENDPOINT_URL);
httpClient.executeMethod(httpMethod);
謝謝, Hemant
請提供一個API文檔的鏈接,因爲它並不完全清楚您所指的提供商「CX」。 – 2012-08-01 16:47:15
它在這裏 - http://developer.cx.com/docs – Hemant 2012-08-06 06:55:27
你是否嘗試過使用不同的OAuth提供程序的相同代碼,只是爲了驗證問題出在CX上? – bruz 2012-08-07 20:26:12