Closed Demon520-coder closed 3 years ago
A bit weird declaration style, you're using.
Here's my implementation, working properly:
const userManagerConfig = {
client_id: '2AD145F6-4A18-46B1-AAF1-E1D6EABEEB52',
redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/auth/callback`,
response_type: 'token id_token',
scope: 'openid profile',
authority: 'https://localhost:5000',
silent_redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/silent_renew.html`,
automaticSilentRenew: true,
filterProtocolClaims: true,
loadUserInfo: true,
🔴 userStore: new WebStorageStateStore({ store: window.localStorage })
};
const userManager = createUserManager(userManagerConfig);
Package version: "oidc-client": "^1.10.1",
A bit weird declaration style, you're using.
Here's my implementation, working properly:
const userManagerConfig = { client_id: '2AD145F6-4A18-46B1-AAF1-E1D6EABEEB52', redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/auth/callback`, response_type: 'token id_token', scope: 'openid profile', authority: 'https://localhost:5000', silent_redirect_uri: `${window.location.protocol}//${window.location.hostname}${window.location.port ? `:${window.location.port}` : ''}/silent_renew.html`, automaticSilentRenew: true, filterProtocolClaims: true, loadUserInfo: true, 🔴 userStore: new WebStorageStateStore({ store: window.localStorage }) }; const userManager = createUserManager(userManagerConfig);
Package version:
"oidc-client": "^1.10.1",
what is createUserManager
?
@muhammedMoussa it´s a method that encapsulates UserManager from 'oidc-client'.
import { UserManager } from 'oidc-client';
export default function createUserManager(config) {
return new UserManager(config);
}
Your code was ok, but you need to make it the same in the callback.html (where the user is actually stored in the storage): new Oidc.UserManager({ response_mode: "query", userStore: new Oidc.WebStorageStateStore({ store: window.localStorage }) }).signinRedirectCallback().then(function () { ... }
@florintaranu-bac-lac That's right. I have do it as you say. Thank you very much! But the oidc-doc dosen't point this. It may take someone a lot time to resolve it.
I use the oidc-client.js for my vue app. My authorize server is identityserver4. I have a problem about localStorage. When I set the userStore:new Oidc.WebStorageStateStore({ store: window.localStorage }) in UserManagerSettings,it writes the userinfo into sessionStorage not to the localStorage. Here is my code, can anyone know what's wrong with it. Thanks a lot.