#Java 8 OAuth2 using spring boot token generation

1 messages · Page 1 of 1 (latest)

unborn scroll
#

Hi, I'm currently running into issues trying to generate access token from the OAuth2 in my spring boot application. I'm running into issues specifically spring security. I'm adding the spring-security-oauth2-client dependency into the project but can't be using OAuth2AuthorizedClientManager since we're struck with spring boot version 2.1.x and spring security 5.1.X. Any thoughts?

pulsar lindenBOT
#

<@&1004656351647117403> please have a look, thanks.

modest shuttle
unborn scroll
#

Thanks. Was finally able to get a work around with it.

HttpPost httppost = new HttpPost("url");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("grant_type", "client_credentials"));
nameValuePairs.add(new BasicNameValuePair("client_id", "client-id"));
nameValuePairs.add(new BasicNameValuePair("client_secret", "client-secret"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

// Execute HTTP Post Request
CloseableHttpResponse response = httpclient.execute(httppost);
return ResponseEntity.ok(EntityUtils.toString(response.getEntity()));
pulsar lindenBOT
# unborn scroll Thanks. Was finally able to get a work around with it. ```java HttpPost httppo...

Detected code, here are some useful tools:

Formatted code
HttpPost httppost = new HttpPost("url");
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("grant_type", "client_credentials"));
nameValuePairs.add(new BasicNameValuePair("client_id", "client-id"));
nameValuePairs.add(new BasicNameValuePair("client_secret", "client-secret"));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
CloseableHttpResponse response = httpclient.execute(httppost);
return ResponseEntity.ok(EntityUtils.toString(response.getEntity()));