npm angular-oauth2-oidc 令牌已过期问题

问题描述

enter image description here

在我的应用程序中间,我收到“令牌已过期”问题,请帮助我如何订阅令牌过期方法并注销应用程序或增加过期时间。请找到以下错误截图供您参考。提前致谢。

解决方法

您需要在令牌过期前刷新令牌。查看文档 here (if you're using Code Flow)here (if you're using implicit flow)

在您的 fun triggerRestart(context: Activity) { val intent = Intent(context,MainActivity::class.java) intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) context.startActivity(intent) if (context is Activity) { (context as Activity).finish() } Runtime.getRuntime().exit(0) } 文件中,您还可以尝试在配置 oAuthService 后(调用 app.component.ts 后)订阅“token_expires”事件

this.oauthService.loadDiscoveryDocumentAndTryLogin();