{"action":"created","issue":{"url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/10","repository_url":"https://api.github.com/repos/IdentityModel/oidc-token-manager","labels_url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/10/comments","events_url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/10/events","html_url":"https://github.com/IdentityModel/oidc-token-manager/issues/10","id":100071747,"number":10,"title":"Add token expiring setting","user":{"login":"appetere","id":1777396,"avatar_url":"https://avatars.githubusercontent.com/u/1777396?v=3","gravatar_id":"","url":"https://api.github.com/users/appetere","html_url":"https://github.com/appetere","followers_url":"https://api.github.com/users/appetere/followers","following_url":"https://api.github.com/users/appetere/following{/other_user}","gists_url":"https://api.github.com/users/appetere/gists{/gist_id}","starred_url":"https://api.github.com/users/appetere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/appetere/subscriptions","organizations_url":"https://api.github.com/users/appetere/orgs","repos_url":"https://api.github.com/users/appetere/repos","events_url":"https://api.github.com/users/appetere/events{/privacy}","received_events_url":"https://api.github.com/users/appetere/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-10T13:54:07Z","updated_at":"2016-02-07T22:34:25Z","closed_at":null,"body":"When using the TokenManager with silent token renewal, and multiple tabs open in the browser, each instance of the TokenManager will try to renew the token at roughly the same time (as outlined in https://github.com/IdentityServer/IdentityServer3.Samples/issues/111).\r\n\r\nIf each TokenManager had a randomised time for firing the TokenExpiring callbacks (for example within the range 45 - 75 seconds instead of hard-coded at 60 seconds) then the TokenManager with the shortest time would effectively act as the \"master\" for all TokenManagers.\r\n\r\nThis could be achieved by exposing the time at which early expiry should happen as a setting:\r\n````\r\nfunction TokenManager(settings) {\r\n    this._settings = settings || {};    \r\n    this._settings.token_expiring_threshold = this._settings.token_expiring_threshold || 60;\r\n````\r\n````\r\nfunction configureTokenExpiring(mgr) {\r\n [...]\r\n    function configure() {\r\n        cancel();\r\n\r\n        if (!mgr.expired) {\r\n            var duration = mgr.expires_in;\r\n            var expiringThreshold = mgr._settings.token_expiring_threshold;\r\n            if (duration > expiringThreshold) {\r\n                setup(duration - expiringThreshold);\r\n            }\r\n            else {\r\n                callback();\r\n            }\r\n        }\r\n    }\r\n````\r\nThen each instance of the TokenManager could be setup with randomised times, such as:\r\n````\r\nvar config = {\r\n   [...]\r\n    token_expiring_threshold: 45 + Math.floor(Math.random() * 30),\r\n};\r\n\r\nvar mgr = new OidcTokenManager(config);\r\n````\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/comments/181135348","html_url":"https://github.com/IdentityModel/oidc-token-manager/issues/10#issuecomment-181135348","issue_url":"https://api.github.com/repos/IdentityModel/oidc-token-manager/issues/10","id":181135348,"user":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"created_at":"2016-02-07T22:34:25Z","updated_at":"2016-02-07T22:34:25Z","body":"Just following up on this -- how are you using this feature now? Just staggering the different tabs so they don't step on each other?"}}