angular - ng-oidc-client:clientSettings.userStore 不是函数
问题描述
遵循此设置指南时,我clientSettings.userStore is not a function
在加载页面时得到。
我复制了 oidc_config 对象,并简单地更改了权限:
StoreModule.forRoot({}),
EffectsModule.forRoot([]),
NgOidcClientModule.forRoot({
oidc_config: {
authority: 'http://localhost:49853/',
client_id: 'ng-oidc-client-identity',
redirect_uri: 'http://localhost:49853/callback.html',
response_type: 'id_token token',
scope: 'openid profile offline_access api1',
post_logout_redirect_uri: 'http://localhost:49853/signout-callback.html',
silent_redirect_uri: 'http://localhost:49853/renew-callback.html',
accessTokenExpiringNotificationTime: 10,
automaticSilentRenew: true,
userStore: new WebStorageStateStore({ store: window.localStorage })
},
log: {
logger: console,
level: Log.NONE
}
})
并添加了相应的资产文件:
"assets": [
"src/favicon.ico",
"src/assets",
{
"glob": "**/*",
"input": "src/static",
"output": "/"
},
{
"glob": "oidc-client.min.js",
"input": "node_modules/oidc-client/dist",
"output": "/"
}
],
版本:
"@ngrx/effects": "7.4.0",
"@ngrx/store": "7.4.0",
"ng-oidc-client": "1.0.5",
"oidc-client": "^1.9.1"
我已经尝试修改版本控制,因为我正在运行 Angular 7,但 npm 默认情况下会在 8 上安装依赖项。但是到目前为止似乎没有任何工作。
解决方案
您需要提供用户存储作为这样的功能。
export function getWebStorageStateStore() {
return new WebStorageStateStore({ store: window.localStorage });
}
NgOidcClientModule.forRoot({
oidc_config: {
authority: 'http://localhost:49853/',
client_id: 'ng-oidc-client-identity',
redirect_uri: 'http://localhost:49853/callback.html',
response_type: 'id_token token',
scope: 'openid profile offline_access api1',
post_logout_redirect_uri: 'http://localhost:49853/signout-callback.html',
silent_redirect_uri: 'http://localhost:49853/renew-callback.html',
accessTokenExpiringNotificationTime: 10,
automaticSilentRenew: true,
userStore: getWebStorageStateStore
},
log: {
logger: console,
level: Log.NONE
}
}
推荐阅读
- laravel - Laravel:使用多列进行身份验证
- python - Pandas Dataframe:df 添加来自另一个 df1 数据框的列
- java - 如何在使用 Streams 时访问相应的内部列表项
- angular - 如何使用AngularFire2获取firebase中元素的键?
- bash - 注意在 bash while 循环中出现超时的日志行
- ajax - 在 Wordpress 中使用 ajax 更新 meta_key
- javascript - 如何检查对象上是否存在多个属性而不会过于冗长?
- html - 这段代码不会将 div 分成两列,我该如何实现?
- macos - VMware,macOS 应用程序在手动工作时无法写入 USB 笔式驱动器
- python - 我正在一个需要用户注册和登录的网站上工作,但是在使用 django 向 auth_user 添加附加字段时遇到问题