Good afternoon,
I'm working on a project with 2 apps, the first one is a php app that provides me an API. The second one is the app that I'm working on (Java 8 base, no Spring) My question is : Can I use the Bearer token authorization using the HttpURLConnection object ?
I'm still trying to make this work but it seems to make the value of "Authorization" null.
//responseLogin is the token that the php app provides.
String token = "Bearer " + responseLogin.toString();
HttpURLConnection httpApi = (HttpURLConnection) apiUrl.openConnection();
httpApi = (HttpURLConnection) apiUrl.openConnection();
httpApi.setRequestMethod("GET");
httpApi.setDoOutput(true);
httpApi.setRequestProperty("Content-Type", "application/json");
httpApi.setRequestProperty("Accept", "*/*");
httpApi.setRequestProperty("Authorization", token);
httpApi.setRequestProperty("Connection", "keep-alive");
httpApi.setRequestProperty("Accept-Encoding", "gzip, deflate, br");
LOG.info("Token : " + httpApi.getRequestProperty("Authorization"));
LOG.info("Accept : " + httpApi.getRequestProperty("Accept"));
httpApi.getRequestProperty("Authorization")); this part gets me a null response, I have no idea why.
I Hope anyone can help me with that, feel free to ask me if you need more information about my code.
Thanks :)