【发布时间】:2016-04-25 21:33:46
【问题描述】:
我正在尝试从服务器响应中获取令牌,它适用于 postMan ,但是当使用 android 调试它时会出错:
unsupported_grant_type
这是我的代码:
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(LoginURL);
post.setHeader("Content-Type", "application/x-www-form-urlencoded");
// post.setHeader("Accept", "application/x-www-form-urlencoded");
JSONObject obj = new JSONObject();
try {
obj.put("grant_type", "password");
obj.put("password", PasswordEditText);
obj.put("username", EmailEditText+"gfg");
post.setEntity(new StringEntity(obj.toString(), "UTF-8"));
HttpResponse response = client.execute(post);
HttpEntity entity = response.getEntity();
results = EntityUtils.toString(entity);
myObject = new JSONObject(results);
【问题讨论】:
标签: java android json api token