在 Vue 应用程序中静默更新无限循环

ric*_*096 0 javascript asp.net-identity vue.js identityserver4 oidc-client-js

我有一个 Vue 应用程序,我试图在其中设置静默令牌更新。

我的 Oidc 配置如下所示:

var mgr = new Oidc.UserManager({
    authority: process.env.VUE_APP_IDENTITY_URL,
    client_id: process.env.VUE_APP_CLIENT_ID,
    redirect_uri: process.env.VUE_APP_REDIRECT_URI,
    scope: 'openid profile',
    response_type: 'id_token token',
    silent_redirect_uri: process.env.VUE_APP_SILENT_REDIRECT_URI,
    userStore: new Oidc.WebStorageStateStore({store: localStorage}),
    automaticSilentRenew: true,
    filterProtocolClaims: true,
    loadUserInfo: true,
})
Run Code Online (Sandbox Code Playgroud)

我还有一个静态的silent-renew.html 页面:

<!DOCTYPE html>
<html>
<head>
    <title>Silent Renew Token</title>
</head>
<body>
    <script src='oidc-client.min.js'></script>
    <script>        
        new Oidc.UserManager().signinSilentCallback().catch((err) => {
            console.log(err);
        });
    </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

当我加载应用程序时,静默更新只是无限循环:

http请求

我的访问令牌不会再过期一个小时,但它仍在触发事件,我无法深入了解。有谁知道还有什么可能导致这个循环?

ric*_*096 5

通过monitorSession: false在客户端设置中进行设置来修复。将此设置为 true 会导致对令牌到期进行重复检查。