cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI/PO - Dynamic Token Authentication for REST Receiver every 12 hours.

ashwathnaik
Explorer
0 Kudos

Hi,

I have a requirement to integrate with Movilitas Cloud API. We have token based authentication and I need to call api using REST adapter in SAP PI. The auth token has to be passed in the JSON header, but the token expires every 12 hours. I need to request the token once in 12 hours and every outgoing message within this time period should use the same token and not request a new token for every request. Kindly provide your valuable suggestions on how to achieve this.

I am thinking of a scheduled interface only to get the token and store it in a VMR. The actual interface uses the value from VMR in the mapping and then call the API.

0 Kudos

Hi Ashwath,

I also have similar requirement. How did you develop this interface ?

Thanks

Accepted Solutions (0)

Answers (1)

Answers (1)

PriyankaAnagani
Active Contributor

Hi Ashwath,

Your approach of creating 2 separate interfaces looks fine. If you want the same to be achieved in single interface then I would suggest storing the token & timestamp locally and then performing a lookup. i.e.

1. When calling for the first time(when there is no token in local table), get the auth token, store both the token as well as timestamp in local table.

2. For all subsequent calls, get the timestamp from table and compare it with current timestamp.

3. If the time difference is >= 12 hours, get a new token and replace the token & timestamp on table.

4. If the time difference is less than 12 hours proceed with calling the API using the existing token.

--Priyanka