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










用浏览器访问也一样。


共4个回复

lizg

2015-04-08 23:54

这个是没有权限,是不是token过期了,您重新获取token再试试

tadeguodu

2015-04-11 16:30

原来是我的url没有改成自己的APPKEY

ebpangyong

2015-04-13 10:22

看你的请求的url 上面demo的appkey 没有去掉,改成自己的就好。请求的url是https://a1.easemob.com/{org_name}/{app_name}/

tadeguodu

2015-04-20 18:45

三楼正解
点击此处继续提问与开发者们互动

申请试用

提交后工作人员会尽快与您联系进行功能演示
技术咨询已转移到管理后台,请先登录

即时通讯云使用者请在应用详情页面咨询
客服云使用者请进入管理员模式咨询

×

在线咨询

电话咨询

技术咨询

免费试用