I am using react-adal
library to connect to ADFS
. I am using axios
interceptor to aquire token which will refresh the token silently as written in the docs, But it refresh the page when token is expired, let's user is filling the form and token expire, it refresh the page and lost all the data.
Please find the below code:
axiosApi.interceptors.request.use((config) => {
return new Promise((resolve, reject) => {
let azureToken = adalInstance.getCachedToken(adalConfig.resource)
if (azureToken) {
adalInstance.acquireToken(adalConfig.endpoints.api, (message, token, error) => {
console.log(error);});
config.headers.Authorization = "Bearer " + azureToken;
resolve(config);}
else {
adalInstance.login();
}
});
});
Is there any way it can be done in the background and user doesn't have to see any interruption.