cancel
Showing results for 
Search instead for 
Did you mean: 

Access Token Reuse in SalesForce integration in CPI

0 Kudos

Hi CPI Experts,

I am working on SalesForce Integration.(ECC -> CPI -> SalesForce).It is Idoc to REST API call for Material master interface.

We are using access token for authorization.For each Idoc, authentication login API is called which causes performance problem.Salesforce team asked to reuse the access token until its validity.But in Login API,there is no expiry time and SF is not sure of access token validity time.

How to reuse the access token until its validity.Once gets expired ,new token should be retrieved and call the REST API again. Please let me know how to achieve this in CPI?

Regards,

Karthiga

Accepted Solutions (1)

Accepted Solutions (1)

sunny_kapoor
Advisor
Advisor

Hi Karthiga,

To achieve your use case, one way is to fetch the token again, as and when the API call fail due to expiry token.

Kindly check the following content for your reference:

https://api.sap.com/integrationflow/ADP_Tax_Credits_SuccessFactors_Connector_Call_ADP_API

In this, a seperate integration flow is used to manage the access token and to make an API call.

The following algorithm is used:

1. Read the access token from the local variable and in case nothing is there(for the first time), fetch the new token and save as a local variable in data store.

2. Make the API call and in case of authentication exception (due to access token expiry), fetch the new access token in exception subprocess and update the local variable again.

In the above content, they are also calculating and checking the token expiry but you can ignore this as you do not have any information on token validity.

I hope this will help.

Regards,

Sunny

Answers (4)

Answers (4)

Sriprasadsbhat
Active Contributor

Hello Karthiga,

There is no standard way to achieve it and you need to model your iflow to handle it.You can below consideration.

1) Get the token from Salesforce for first call and store it in variable and use it for first time.

2) Afterwards you read the variable and validate the Token validity if Salesforce provides api to do the same.In case if you receive error response get a new token if not resuse the same.

You might consider multiple scenarios while designing and once you get started complexity eases.

Regards,

Sriprasad Shivaram Bhat

0 Kudos

Hi Sriprasad/Sunny,

SF confirmed token will be valid for 15 minutes and i am using groovy for token validation.Adding 15 minutes to the session time and comparing with current time ,finally setting the session valid var either true/false .Based on this condition ,calling the default router or login API.

Issue:

In case of bulk Idocs(10,000) received from ECC,in one second 10 Idocs received from ECC and after expiry time,authentication Iflow was called 5 to 6 times.Login API should be called only once after 15 minutes.How to fix this issue.

Regards,

Karthiga

0 Kudos

Hi Sriprasad,

How to validate the token expire..SF provided the login API,but it returns only access token and not the expiry/Validity time..

Regards,

Karthiga

yogananda
Product and Topic Expert
Product and Topic Expert
0 Kudos