为什么修改用户密码,总数报error":"unauthorized
请教各位,调用修改用户密码的api,总是报这个错误。下面是我的代码:
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient=WebClientDevWrapper.wrapClient(httpclient);
JSONObject jsonParam = new JSONObject();
HttpPut httpost = new HttpPut("https://a1.easemob.com/easemob-demo/chatdemoui/users/"+username+"/"+oldPassword);
httpost.setHeader("Content-Type", "application/json");
httpost.setHeader("Authorization", "Bearer "+token);
jsonParam.put("newpassword", newpassword);
StringEntity en = new StringEntity(jsonParam.toString(), "utf-8");
httpost.setEntity(en);
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
String responseContent=null;
if (null != entity) {
responseContent = EntityUtils.toString(entity);
}
EntityUtils.consume(entity);
httpclient.getConnectionManager().shutdown();
**.out.println("responseContent:"+responseContent);
返回的错误是:
{"error":"unauthorized","timestamp":1428497620036,"duration":0,"exception":"org.apache.shiro.authz.UnauthorizedException","error_description":"Subject does not have permission "}
用浏览器访问也一样。
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient=WebClientDevWrapper.wrapClient(httpclient);
JSONObject jsonParam = new JSONObject();
HttpPut httpost = new HttpPut("https://a1.easemob.com/easemob-demo/chatdemoui/users/"+username+"/"+oldPassword);
httpost.setHeader("Content-Type", "application/json");
httpost.setHeader("Authorization", "Bearer "+token);
jsonParam.put("newpassword", newpassword);
StringEntity en = new StringEntity(jsonParam.toString(), "utf-8");
httpost.setEntity(en);
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
String responseContent=null;
if (null != entity) {
responseContent = EntityUtils.toString(entity);
}
EntityUtils.consume(entity);
httpclient.getConnectionManager().shutdown();
**.out.println("responseContent:"+responseContent);
返回的错误是:
{"error":"unauthorized","timestamp":1428497620036,"duration":0,"exception":"org.apache.shiro.authz.UnauthorizedException","error_description":"Subject does not have permission "}
用浏览器访问也一样。
没有找到相关结果
已邀请:
4 个回复
lizg - ……
tadeguodu
ebpangyong
tadeguodu