mvertopoulos / vue-msal

Vue plugin for using Microsoft Authentication Library (MSAL)
MIT License
123 stars 66 forks source link

Create a timer to renew the token automatically when it expires #9

Closed mvertopoulos closed 4 years ago

mvertopoulos commented 4 years ago

Quoting from issue #1

The token expiration check is performed on initial page load (where the plugin is initialized), and not when navigating through pages using the vue router. When the token is found to be expired during that check, the user is redirected to the Microsoft login page. A timer for renewing the token on that scenario should indeed solve the problem.

Agendum commented 4 years ago

Hi @mvertopoulos, thanks for logging this issue. In the other issue you said:

How are you checking that the data.accessToken is not automatically renewed?

I tested in two ways: 1) Created a watcher on the access token to see if it ever changed. 2) Used jwt-decode to crack the access token and read the exp field (usually about 1 hour) and waited until that time passed and then tried to use data.accessToken to confirm.

My app is a SPA so the field isn't reset by routing changes, and I anticipate my SPA to be open for long periods of time (which is why i tested it).

Btw, thanks for vue-msal, it has dramatically simplified a typically annoying part of development process!