Authorization Bearer token in HttpClient?
问题 I am trying to access an API using an oauth2 authorization token in Java Here is the client code DefaultHttpClient httpclient = new DefaultHttpClient(); HttpPost post = new HttpPost(http://res-api"); post.setHeader("Content-Type","application/json"); post.setHeader("Authorization", "Bearer " + finalToken); JSONObject json = new JSONObject(); // json.put ... // Send it as request body in the post request StringEntity params = new StringEntity(json.toString()); post.setEntity(params);