1
我正在使用WSO2-AM-1.9.0,嘗試使用使用者密鑰和消費者密鑰生成訪問令牌。 使用curl撥打呼叫時,它工作正常使用令牌API失敗的WSO2令牌生成
curl -k -d "grant_type=password&username=testuser1&password=testUser1&scope=SANDBOX" -H "Content-Type:application/x-www-form-urlencoded" -H "Authorization:Basic ZXNuaHJTZmJmOW9XS28xTVM5UHJSZ1BacUU0YTpld040RGh1ZmsxYTNZbndVNU1uMVlGM3IwanNh" http://10.0.100.108:8280/token
但與Java試圖當它返回403錯誤代碼。代碼是:
try
{
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet("http://10.0.100.108:8280/token");
HttpParams params=new BasicHttpParams();
get.addHeader("Authorization","Basic ZXNuaHJTZmJmOW9XS28xTVM5UHJSZ1BacUU0YTpld040RGh1ZmsxYTNZbndVNU1uMVlGM3IwanNh");
get.addHeader("content-type", "application/x-www-form-urlencoded");
params.setParameter("grant_type", "password");
params.setParameter("username", "testuser1");
params.setParameter("password", "testUser1");
params.setParameter("scope", "SANDBOX");
get.setParams(params);
HttpResponse response = client.execute(get);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
responseBody = responseBody +"\n"+line;
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
錯誤: 403狀態報告 運行時錯誤沒有在API中發現任何幫助和信息理解給定請求
匹配的資源。
它的工作 非常感謝Sajith的幫助。 –