Hi
@Pranjit Biswas,
I think this will help.
I have a similiar solution in a production environment.
<!--
Process-Name: HTTP_JWT
Description: HTTP Request with JWT
Created By: Clayton Snyman
Changes:
========
Date | Owner | Description
===========|=====================|==============================================================================
04/06/2021 | Clayton Snyman | v1.0-00 - Intial version
Notes:
=====
-->
<process name="HTTP_JWT">
<sequence name="Main">
<!-- Retrieve token
Get JWT from a custom properties file or DB.
Using assign in example.
-->
<assign to="JWT/@token"
from="'eyJ0eXBlIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJjdXN0b21lcklkIjoiQ3VzdG9tZXIiLCJleHAiOjE2MjUzODk3NjQsInVzZXJJZCI6IlVzZXIiLCJjdXN0b21lclVzZXJLZXkiOiIwMTIzNDU2Nzg5In0.YyflntcVdHKGH1d_1Hxrcd5AHKuEUmI9IDJ6QFPEaX6bWsuxqbs69C5W7A57ikGQIe3Xq3GeiHGPFivQnt92yM9npIOW_ApsCIcrFtovOLlURXabhhnm-inY5E4xR2_BbY7uF3S1sm3bFK0nL_qEIZwpNGS8vrrihGamBZgwsyakGySMKsqIyyIwAxn6iVHEbqpBrFoTqVgtSWHQ-kShTU-ANrHajw5LrGUMm1cCRPdTny576dO4nmJ8VfKwO8OEXvnjmZavTCiVPbu9SZds9oHqo8oiB_Y_KAFJmG_wEir0XkX3zapGD5DYaI--Ho-0eItTKAdOGGURY_mMC2MVEw'"/>
<!-- DocInfo Service
Set PrimDoc to required Document Content and Sub-Content type
Get DocumentId that will be used to build MIME Message
-->
<operation name="Set Content Type to json:application">
<participant name="GetDocumentInfoService"/>
<output message="xout">
<assign to="." from="PrimaryDocument"/>
<assign to="DocumentContentSubType" from="'json'"/>
<assign to="DocumentContentType" from="'application'"/>
<assign to="updateMetaDataOnly" from="'true'"/>
</output>
<input message="xin">
<assign to="message/doc:document-id" from="string(DocumentId)" />
<assign to="message/@type" from="string(DocumentContentType)" />
<assign to="message/@subType" from="string(DocumentContentSubType)" />
</input>
</operation>
<!-- Assign MIME Message
Assign HTTP required Header KEY and VALUE
VALUE assigned to mime:message/mime:header
KEY assigned to mime:message/mime:header/@name
Assign doc:document-id to mime:body
-->
<operation name="Assign - MIME Header and Body">
<participant name="AssignService"/>
<output message="AssignServiceTypeInputMessage">
<assign to="mime:message/mime:header" from="concat('Bearer ',string(JWT/@token))" append="true"/>
<assign to="mime:message/mime:header/@name" from="string('Authorization')" append="true"/>
<assign to="mime:message/mime:header" from="concat(string(message/@type),'/',string(message/@subType))" append="true"/>
<assign to="mime:message/mime:header/@name" from="string('Content-Type')" append="true"/>
<assign to="mime:message/mime:body" from="message/doc:document-id"/>
</output>
<input message="inmsg">
<assign to="." from="*"/>
</input>
</operation>
<operation name="Assign MIME encode document">
<participant name="MIME"/>
<output message="packRequest">
<assign to="mime-document" from="mime:message"/>
</output>
<input message="packResponse">
<assign to="PrimaryDocument" from="mime-document/@*" />
</input>
</operation>
<!-- SAMPLE OUTPUT From Service
This will become the Primary Document used for HTTP Method
Authorization: Bearer eyJ0eXBlIjoiSldUIiwiYWxnIjoiUlMyNTYifQ.eyJjdXN0b21lcklkIjoiQ3VzdG9tZXIiLCJleHAiOjE2MjUzODk3NjQsInVzZXJJZCI6IlVzZXIiLCJjdXN0b21lclVzZXJLZXkiOiIwMTIzNDU2Nzg5In0.YyflntcVdHKGH1d_1Hxrcd5AHKuEUmI9IDJ6QFPEaX6bWsuxqbs69C5W7A57ikGQIe3Xq3GeiHGPFivQnt92yM9npIOW_ApsCIcrFtovOLlURXabhhnm-inY5E4xR2_BbY7uF3S1sm3bFK0nL_qEIZwpNGS8vrrihGamBZgwsyakGySMKsqIyyIwAxn6iVHEbqpBrFoTqVgtSWHQ-kShTU-ANrHajw5LrGUMm1cCRPdTny576dO4nmJ8VfKwO8OEXvnjmZavTCiVPbu9SZds9oHqo8oiB_Y_KAFJmG_wEir0XkX3zapGD5DYaI\-\-Ho-0eItTKAdOGGURY_mMC2MVEw
Content-Type: application/json
Content-Length: 1629
{"json":"data"}
-->
<!-- HTTP process -->
<operation name="HTTP Session Begin">
<participant name="HTTPClientBeginSession"/>
<output message="HTTPClientBeginSessionServiceTypeInputMessage">
<assign to="." from="*"/>
</output>
<input message="inmsg">
<assign to="." from="*"/>
</input>
</operation>
<operation name="HTTP Method - POST Mandate">
<participant name="HTTPClientMethod"/>
<output message="HTTPClientMethodServiceTypeInputMessage">
<assign to="." from="PrimaryDocument"/>
</output>
<input message="inmsg">
<assign to="." from="*"/>
</input>
</operation>
<operation name="HTTP Session End">
<participant name="HTTPClientEndSession"/>
<output message="HTTPClientEndSessionServiceTypeInputMessage">
<assign to="." from="*"/>
</output>
<input message="inmsg">
<assign to="." from="*"/>
</input>
</operation>
<onFault>
<!-- Handle any errors -->
</onFault>
</sequence>
</process>
Let me know if you have questions or need clarification.
------------------------------
Sincerely,
Clayton Snyman
------------------------------
Original Message:
Sent: Thu June 03, 2021 01:44 AM
From: Pranjit Biswas
Subject: JWT support for Sterling B2Bi 6.0.X
Hello All,
Hope you all are safe and healthy.
We got a new requirement where in our REST API Calls trigerred frm B2Bi currently we are doing basic auth but now they want us to send basic auth to one endpoint, it will generate JWT token and send us back and then using that JWT token, we need to call the actual endpoint .
Is this something feasible in Sterling B2Bi 6.0.X or not supported ? We use B2B Integrator and not File gateway.
------------------------------
Pranjit Biswas
------------------------------