Call REST webservice using Spring Integration and Oauth

北城以北 提交于 2019-12-24 18:43:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!