Skip to Content

How pass the JWT token valuse in the REST receiver adapter header dynamically

Dear experts,

I have a requirement where i need to call the REST API using JWT token authentication which needs to be passed in the header of the request. JWT token will expires on every 15 mins. Please provide your thoughts.


Pavan T

Add comment
10|10000 characters needed characters exceeded

  • Hi Experts,

    Used Below Java mapping to fulfill my requirement.

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException { try{ String inputPayload = convertInputStreamToString(transformationInput.getInputPayload().getInputStream()); String outputPayload = inputPayload.replaceAll("_OUTPUT", "OUTPUT"); transformationOutput.getOutputPayload().getOutputStream().write(outputPayload.getBytes()); transformationOutput.getOutputPayload().getOutputStream().flush(); }catch(Exception ex){ throw new RuntimeException(ex.getMessage()); } } public String convertInputStreamToString(InputStream in) { StringBuffer sb = new StringBuffer(); try { InputStreamReader isr = new InputStreamReader(in); Reader reader = new BufferedReader(isr); int ch; while ((ch = > -1) { sb.append((char) ch); } reader.close(); } catch (Exception localException) { } return sb.toString(); }


    Pavan T

  • Former Member

    Hi Pavan,

    Why do we require Java mapping here as we can pass Custom HTTP headers in REST receiver adapter.

    As far I know, we need to pass the combination of Base64 Encoded string of "header.payload.signature" to HTTP headers.

    We can read the values with Xpath Expression from input payload and can set them to HTTP headers.

    Let me know your Usecase as I have a similar requirement REST to PI to REST with JWT authentication.


    Best Regards,

    Sachin Jangir

  • Get RSS Feed

1 Answer

  • Best Answer
    Nov 17, 2016 at 03:04 PM

    Hello Pravan,

    In PO 7.31 SP15 / PO 7.4 SP10, REST adapter was enhanced with functionality for setting custom HTTP headers (refer to for details and examples). A part which is not available there and which will have to be custom developed (within mapping logic or as a custom adapter module) or purchased from 3rd party, is acquisition of JWT from the authorization server, its parsing and placement of an access token value in dynamic configuration attribute (which value can then be used when setting custom HTTP header using the referred functionality of REST adapter).



    Add comment
    10|10000 characters needed characters exceeded