My API returns below response
But when I am consuming from webclient
public static String accessToken(String jwtToken) {
WebClient webClient = WebClient.create();
final WebClient.ResponseSpec response = webClient.post()
.uri(UriComponentsBuilder.fromUriString("https://account-d.docusign.com/oauth/token")
.queryParam("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")
.queryParam("assertion", jwtToken)
.toUriString())
.retrieve();
System.out.println(response);
return response.toString();
}
response
is
org.springframework.web.reactive.function.client.DefaultWebClient$DefaultResponseSpec@7f0393b5
how can I make the response proper?
when I created custome POJO class
public class JwtToken {
private String access_token;
private String token_type;
private Integer expires_in;
private String scope;
@Override
public String toString() {
return access_token;
}
public String getAccess_token() {
return access_token;
}
public void setAccess_token(String access_token) {
this.access_token = access_token;
}
public String getToken_type() {
return token_type;
}
public void setToken_type(String token_type) {
this.token_type = token_type;
}
public Integer getExpires_in() {
return expires_in;
}
public void setExpires_in(Integer expires_in) {
this.expires_in = expires_in;
}
public String getScope() {
return scope;
}
public void setScope(String scope) {
this.scope = scope;
}
}
and use it like below and used like below
public static String accessToken(String jwtToken) {
WebClient webClient = WebClient.create();
final JwtToken response = webClient.post()
.uri(UriComponentsBuilder.fromUriString("https://account-d.docusign.com/oauth/token")
.queryParam("grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer")
.queryParam("assertion", jwtToken)
.toUriString())
.retrieve()
.bodyToMono(JwtToken.class)
.block();
System.out.println(response);
return response.toString();
}
it is throwing exception.
I only need to extract accesstoken from response. how can I get the same?