首页 > 解决方案 > automaticSilentRenew 不适用于角度 oidc-client 库

问题描述

我正在使用 "oidc-client": "1.10.1" 进行 oidc 身份验证,下面是我对 userManager 的配置

const settings = {
    
    authority: (window as any).__env.auth.authority, //OAuth 2.0 authorization endpoint of the OpenID Provider
    
    client_id: (window as any).__env.auth.clientID, //
    
    redirect_uri: (window as any).__env.auth.redirectUri, //callback URI for the authentication response
    
    response_type: 'id_token token',
    
    scope: 'openid profile api',
    
    automaticSilentRenew: true,
    
    silent_redirect_uri: (window as any).__env.auth.silentRedirectUri,
    
    userStore: new WebStorageStateStore({ store: window.localStorage }),
    
    loadUserInfo: true,
    
    post_logout_redirect_uri: (window as any).__env.auth.postLogoutRedirectUri,
    
    silentRequestTimeout: 30000,
    
};

甚至没有进行静默更新令牌调用,即用户在令牌到期后注销。我错过了什么吗?

PS我想让令牌自动更新工作,因为我手动尝试了令牌更新,它确实有效,但似乎不是一种可靠的方法。

标签: angularopenid-connectoidc-client-js

解决方案


这里有几件事要检查:

  • 是否正在发送续订消息?浏览器工具或 Fiddler 等代理应该会给你一些信息。

  • 您是否从 OIDC 客户端日志中获得有关错误或计时器触发的任何信息?控制台输出可能会有所帮助。

  • 您是否正在处理续订响应?您通常需要调用用户 manager.signInSilentCallback。

  • 或者可能只是因为令牌不在到期后 5 分钟内而没有发生更新。

在此处输入图像描述

我的资源

请注意,在我的情况下,我没有使用单独的 HTML 文件进行更新,而是使用 index.html 和此启动代码


推荐阅读