1

I am building an aurelia app using adal JS for authentication. After 1-hour token gets expired and after that not API is called. I think the problem is in renewing the token. I set the interval of 5 minutes to check the validity of token. I am using handleWindowCallback when I get the token initially.

 window.setInterval(function(){
       self.authorizeStep.authContext.adal.acquireToken(self.authorizeStep.authContext.adal.config.clientId, (x)=> {
                console.log('acquiretoken callback hit!')       })
                 self.authorizeStep.authContext.adal.handleWindowCallback();
       },50*1000)

These line of code are used in app.js. It throws the 401 unauthorised access. These are the image of error.

error1

error

praval
  • 206
  • 1
  • 3
  • 14
  • Are you getting `acquiretoken callback hit!` every 5 minutes? Does the callback work? What are your console and network logs when you call `acquireToken`? – Fred Kleuver May 26 '18 at 20:22
  • @FredKleuver yes, I am getting acquiretoken callback hit! in every 5 minutes but after token expired it did not get hit. Callback is also working. I am new in the Aurelia can you suggest me what else can I do. – praval May 27 '18 at 05:07
  • You're not giving the information we need to help you. Where is the token being stored? What is your ADAL configuration? How is ADAL configured to retrieve the token (from whatever storage mechanism it's stored in) when the page loads? – Fred Kleuver May 27 '18 at 18:35
  • @FredKleuver Sorry for info. Token is stored in session storage and for adal I am attaching the link here you can see that my App.js file and auth.js file for adal configuration. Actually token should be renewed automatically after one hour but when adal get token from session storage after the expired time then it gets failed and after that for every API call it throw 401 unauthorised and one thing can you suggest the where I have to put the window callback in my code if you need anything I will share thanks for help https://github.com/pj41195/adal-issue you can see here issue section – praval May 28 '18 at 16:40

0 Answers0