注册

为什么修改用户密码,总数报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 "}










用浏览器访问也一样。


已邀请:

lizg - ……

这个是没有权限,是不是token过期了,您重新获取token再试试
原来是我的url没有改成自己的APPKEY
看你的请求的url 上面demo的appkey 没有去掉,改成自己的就好。请求的url是https://a1.easemob.com/{org_name}/{app_name}/

要回复问题请先登录注册