vue-adal
vue-adal copied to clipboard
After 1 hour JWT Token is getting expired , how to renew the token automatically
After 1 hour JWT Token is getting expired , how to renew the token automatically
Code
Vue.use(Adal, { config: { tenant: process.env.TENANT_ID, clientId: process.env.CLIENT_ID, redirectUri: process.env.REDIRECT_URI, cacheLocation: "localStorage" }, requireAuthOnInitialize: true, router: router });
Vue.use({ install(vue, opts = {}) { // Configures an axios http client with a interceptor to auto-acquire tokens vue.prototype.$graphApi = AxiosAuthHttp.createNewClient({ // Required Params axios: axios, resourceId: graphApiResource, // Resource id to get a token against
// Optional Params
router: router, // Enables a router hook to auto-acquire a token for the specific resource
baseUrl: graphApiBase, // Base url to configure the client with
onTokenSuccess(http, context, token) {
store.commit("shift/updateToken", token);
// Token success hook
// When an attempt to retrieve a token is successful, this will get called.
// This enables modification of the client after a successful call.
if (context.user) {
// Setup the client to talk with the Microsoft Graph API
http.defaults.baseURL = `${graphApiBase}/${context.user.profile.tid}`;
}
},
onTokenFailure(error) {
// Token failure hook
// When an attempt to retrieve a token is not successful, this will get called.
console.log(error);
}
});
}
});