0

I have to send a request to a rest using HttpUrlConnection but recently the provider added client credentials auth flow.

I have all I need and it tried to generate the token thru postman and then set a bearer on the request but the token expires after 2 days. The project uses Java 6 EE and i can't change the version because it will be decomisioned in about a year.

How can i make my java code generate the token?

  • 1
    You can send the request with java, extract the token and set it in your other request. When the token expires, repeat the process. [Java - sending HTTP parameters via POST method easily](https://stackoverflow.com/questions/4205980/java-sending-http-parameters-via-post-method-easily) and [How to get response body using HttpURLConnection, when code other than 2xx is returned?](https://stackoverflow.com/questions/25011927/how-to-get-response-body-using-httpurlconnection-when-code-other-than-2xx-is-re) should help dealing with the request. – Chaosfire Nov 18 '22 at 10:13
  • I tried to use the following method wich is used in other areas of the app but I still get 401: – Dinu VA Nov 28 '22 at 11:36
  • https://stackoverflow.com/questions/74600145/401-encountered-when-generating-token-with-client-credentials-java-6-ee – Dinu VA Nov 29 '22 at 10:48

0 Answers0