Skip to Content
0
Oct 13, 2022 at 02:39 PM

Refresh CSRF token for MDK client/application

586 Views

Hello experts,

We noticed, that sometimes our MDK application receives an HTTP exception from the backend:

Error: com.sap.cloud.mobile.odata.http.HttpException: https://ilobmwui-dev-scm-ewm-ilo-rtop-dd.cfapps.sap.hana.ondemand.com; Caused by: com.sap.cloud.mobile.odata.core.RuntimeIOException; Caused by: java.io.IOException: No CSRF token found in response.

The reason is clear: CSRF token is expired, because it is set to 30 minutes at the backend. Now I am looking for a way to refresh this token without logout and logon again. Following documentation and instructions how to use CSRF, I tried to put header parameter "X-CSRF-Token" with value "fetch" to the request, but this does not help.

I am wondering is there any standard way to refresh this token with any MDK API, or what you can recommend in this case?

Note: ServiceOption requiresToken is not even activated explicitly is or service metadata. I checked clientAPI.getODataProvider("/rtop/Services/tour.service") for any service related method but its methods are very limited

Any hint, recomendation, suggestion will be highly appretiatedBest Regards,Dimiter