Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
pooja_tiwari3
Participant
Introduction –

Since we are aware that SAP CPI does not support OAuth 2.0 with grant-type any other than “Client Credentials”, in this blog we will be learning about fetching bearer token from “grant-type=password” and fetch JWT token from the bearer token and Authenticate a Standard CPQ API.

Design-

In this blog ,we will be creating 2 iflows. 1st for calling standard CPQ API and get the data from CPQ and 2nd iFlow will be called from 1st iFlow to get bearer token and JWT token and authenticate CPQ API in 1st iFlow.

Here We will have 2 blogs explaining each iFlow in details.

Token Concept-

To get the Bearer token, we make a call to CPQ token API from postman app with grant type=password,

Username, password and Domain=”xyzCPQdev/test/prod”(this value is company and environment specific) and content type is ‘x-www-form-urlencoded’.

 



When we get the bearer token ,We make a call to JWT token URL and provide previously received Bearer token as authentication method and send a GET method to get JWT token in return.


 

IFLOW2-

In this IFlow ,we will fetch Bearer token with “Grant-type=password” and then JWT with the help of Bearer token.

Here we will be making a call to this iflow from our Main iflow via ProcessDirect Adapter.

.


 

In Content Modifier 001 we will be sending data to Token URL and defining the payload

When we post the form, the payload for “ x-www-form-urlencoded “looks like below:

username=abcd&password=abcdef and same we will be using in Content Modifier


 

in Request-Reply 1, we will make Get call to token API, since we have already provided credentials in Body, no need to pass again in HTTP adapter:

 


 

In Content Modifier 002 we will be saving the response  received from Token URL call.


 

Then in Groovy script 1 we are simply adding Root node to JSON response.(same script used in 1st blog).

Then using JSON to XML converted to get the xml.

Then in Content Modifier 003, saving the access token.


In Content Modifier 004 we are creating Authorization header with word “Bearer” and token received from last call.

 


In Request reply 2 ,we are making call to fetch JWT token


 

In Content Modifier 005 ,we are saving the response received


Then in Groovy script 2, adding the root to Json received as response before converting to XML and then using JSONtoXML converted to get XML before sending it back to main iflow.

 


 

With this design, out iflow 2 is completed and we get JWT token from Bearer token .

Link for blog 1(iflow1)- SAP CPI – Calling CPQ REST API in CPI and fetch the data from CPQ


Session and Cookie management- CPQCPI3-Fetching CPQ Cookie to pass them while calling CPQ REST API via POST method | SAP Blogs

 

Thank you so much for reading the blog.

Any comments are most welcome.

Thanks and Regards,

Pooja Tiwari

 
2 Comments
Labels in this area