首页 新闻 会员 周边

vue 使用 oidc-client 连接IdentityServer4

0
悬赏园豆:10 [已解决问题] 解决于 2020-10-16 11:27

authority: "http://192.168.1.50:2000", //授权新中心
授权地址用本址localhost使用没有问题,但如果使用192.168.1.50的服务器,在callback页面上就会报错:Error: No matching state found in storage
at OidcClient.js:121

<template></template>

<script>
import Oidc from "oidc-client";

import { UserManager } from "oidc-client";
const userManagerConfig = {
  client_id: "localadmin", //storeadmin
  redirect_uri: `http://localhost:8080/callback.html`,
  response_type: "code",
  scope:
    "openid profile master notification article catalog message filemanagement",
  authority: "http://192.168.1.50:2000", //授权新中心
  silent_redirect_uri: `http://localhost:8080/silentRenews.html`,
  automaticSilentRenew: true,
  filterProtocolClaims: true,
  loadUserInfo: true,
  monitorSession: true,
};
var manager = new UserManager(userManagerConfig);
export default {
  beforeCreate() {
    manager.signinRedirect();
  },
};
</script>

callback.html

new Oidc.UserManager({ response_mode: "query" }).signinRedirectCallback().then(function () {
            window.location = "/";
        }).catch(function (e) {
            console.error(e); //此处获取到错误信息:Error: No matching state found in storage
    at OidcClient.js:121
        });
浪潮之巅的主页 浪潮之巅 | 初学一级 | 园豆:83
提问于:2020-10-15 17:19
< >
分享
最佳答案
3

原来是因为时间的问题,我的服务器时间不正确。。

浪潮之巅 | 初学一级 |园豆:83 | 2020-10-16 11:26
其他回答(1)
0

你好,我也遇到类似的问题了,本地vue项目,id4服务在服务器上,id4的客户端绑定的是localhost:8080,本地vue项目也是8080,能跳转回来,但是立刻就闪退,后端日志:Showing login: User is not authenticated,请问是什么原因呢

文艺青年cc | 园豆:206 (菜鸟二级) | 2022-04-24 20:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册