Fix issue related to refreshing access tokens

This commit is contained in:
Marcial Rosales 2022-07-07 11:10:03 +02:00
parent 5c4e92ba25
commit 745ff0b4b2
1 changed files with 8 additions and 6 deletions

View File

@ -34,7 +34,6 @@ function auth_settings_apply_defaults(authSettings) {
if (!authSettings.oauth_scopes) {
authSettings.oauth_scopes = "openid profile " + authSettings.oauth_resource_id + ".*";
}
}
if (!authSettings.oauth_response_type) {
authSettings.oauth_response_type = "code"; // although the default value in oidc client
@ -44,8 +43,6 @@ function auth_settings_apply_defaults(authSettings) {
authSettings.oauth_scopes = "openid profile";
}
return authSettings;
}
@ -98,12 +95,17 @@ function oauth_initialize(authSettings) {
mgr.events.addAccessTokenExpiring(function() {
console.log("token expiring...");
});
mgr.events.addAccessTokenExpired(function() {
console.log("token expired !!");
});
mgr.events.addAccessTokenExpired(function() {
console.log("token expired !!");
});
mgr.events.addSilentRenewError(function(err) {
console.log("token expiring failed due to " + err);
});
mgr.events.addUserLoaded(function(user) {
let expiryDate = new Date(user.expires_at * 1000) // it is epoch in seconds
console.log("user loaded with token which expires at " + expiryDate);
oauth.access_token = user.access_token;
});
return oauth;
}