Skip to Content

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

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Mar 10, 2020 at 09:27 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.