管理首页
请求access_token时遇到21323错误
报错信息:
error":"invalid_request","error_code":21323,"request":"/oauth2/access_token","error_uri":"/oauth2/access_token","error_description":"miss client id or secret“
解决方案:
参照文档:http://open.weibo.com/wiki/OAuth2/access_token,这里写的是POST提交,但是这里的post的URL为
https://api.weibo.com/oauth2/access_token?client_id=client_id&client_secret=client_secret&grant_type=authorization_code&code=code&redirect_uri=redirect_uri
提交的data应该为空
参考代码:
// 获取access_token
String url = "https://api.weibo.com/oauth2/access_token?client_id=" + OtherConfig.WEIBO_APP_ID+ "&client_secret=" + OtherConfig.WEIBO_APP_SECRET+ "&grant_type=authorization_code&code="+code+"&redirect_uri="+OtherConfig.WEIBO_BACK_URI;
HttpPost httpPost = new HttpPost(url);
JSONObject json = new JSONObject();
String response = HttpClientUtils.doPost(httpPost, json.toJSONString());
成功解决,这里的data必须为空
|