on 05-18-2020 6:09 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karthiga
you can refer to this link which will solve your problem
https://blogs.sap.com/2019/09/09/sap_cpi-integration-with-sfdc/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
94 | |
11 | |
11 | |
10 | |
9 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.