问题
My goal is to perform a call to a REST webservice using an outbound gateway, this webservice needs a token provided by another web service. I've tried using Spring oauth without any luck since I am not sure how to integrate both frameworks.
<int:chain input-channel="requestChannel">
<int-http:outbound-gateway
url="https://webservice.url/..."
http-method="GET" expected-response-type="java.lang.String"
rest-template="restTemplate" />
...
</int:chain>
<oauth:resource id="oauth1" client-id="admin"
access-token-uri="https://token.priovider.url/..."
client-secret="secret" client-authentication-scheme="header" type="password"
scope="trust" password="mypassword" username="myusername" />
<oauth:rest-template id="restTemplate" resource="oauth1" />
Token webservice response format:
{
"signInResponse":{
"duration":86400000,
"token":"sKgRT6748UH0h_XEdIUYsUDSkBDUMKCW",
"userName":"myusername",
"userId":"http://identity.auth.service.com/100046",
"idleTimeout":14400000
}
}
While I was debugging I found in the following line (OAuth2RestTemplate constructor), the value of "context" is "com.sun.jdi.InvocationException occurred invoking method.":
public OAuth2RestTemplate(OAuth2ProtectedResourceDetails resource, OAuth2ClientContext context)
来源:https://stackoverflow.com/questions/36861053/call-rest-webservice-using-spring-integration-and-oauth