【发布时间】:2017-09-05 07:28:15
【问题描述】:
我试图使用身份验证值向服务器发送响应,它在登录时为我提供。服务器仅在发送该值时接受请求。但是它适用于postman (see snapshot),但不适用于我的代码。
代码
URL url = new URL(strings[0]);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
String token = "" + new String(accessToken);
con.setRequestMethod("GET");
con.setRequestProperty("AuthToken", token);
con.setReadTimeout(15000);
con.setConnectTimeout(15000);
con.setDoOutput(false);
我也试过这种方式
String token = "AuthToken :" + new String(accessToken);
con.setRequestProperty("Authorization", token);
【问题讨论】:
-
我正在通过 GET 方法发送请求
标签: android get httpurlconnection http-token-authentication