My REST request looks like this after I read through this guide: How to Authorize to Microsoft Azure-AD
Client cli = ClientBuilder.newClient();
WebTarget webTar = cli.target("https://login.microsoftonline.com/yyyyy.onmicrosoft.com/oauth2/authorize").queryParam("response_type", "code");
webTar = webTar.queryParam("client_id", "ed4d67dc-34a8-4eb3-9058-49f39yyyyyy");
webTar = webTar.queryParam("redirect_uri", URLEncoder.encode("https://xyxyxyx.onmicrosoft.com/o365jso", "UTF-8"));
String response = webTar.request(MediaType.APPLICATION_JSON).get(String.class);
However I am receiving a full HTML as response which concludes that the endpoint thinks I am a browser. Is there a way to somehow proceed correctly (in form of a URL to authorization side) to receive the authorization code and afterwards access Token for Sharepoint/Exchange afterwards with Java Jersey?