question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot store token in session storage

See original GitHub issue

I used your example as my starting point but I can’t store token in session storage. I read your source code and in oidc-helpers.js there is:

const defaultOidcConfig = {
  userStore: new WebStorageStateStore(),
  loadUserInfo: true
}

which is used for building oidc UserManager object. new WebStorageStateStore() is by default storing in localStorage (https://github.com/IdentityModel/oidc-client-js/blob/dev/src/WebStorageStateStore.js) and I can’t pass any parameters to it. Can you help me with this?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
perarnborgcommented, Apr 29, 2019

OK, so this is how you would change the example app to use sessionStorage:

import Vue from 'vue'
import Vuex from 'vuex'
import { vuexOidcCreateStoreModule } from 'vuex-oidc'
import { oidcSettings } from './config/oidc'
import { WebStorageStateStore } from 'oidc-client'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    oidcStore: vuexOidcCreateStoreModule(
      {
        ...oidcSettings,
        userStore: new WebStorageStateStore({ store: window.sessionStorage })
      },
      // Optional OIDC store settings
      {
        namespaced: true,
        dispatchEventsOnWindow: true
      },
      // Optional OIDC event listeners
      {
        userLoaded: (user) => console.log('OIDC user is loaded:', user),
        userUnloaded: () => console.log('OIDC user is unloaded'),
        accessTokenExpiring: () => console.log('Access token will expire'),
        accessTokenExpired: () => console.log('Access token did expire'),
        silentRenewError: () => console.log('OIDC user is unloaded'),
        userSignedOut: () => console.log('OIDC user is signed out')
      }
    )
  }
})
0reactions
ux-engineercommented, Aug 30, 2020

'userStore' does not exist in type 'VuexOidcClientSettings'.ts(2345)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Store Session Tokens in a Browser (and the impacts of ...
A common question when building a SPA is: where do I store my session tokens? I'll talk through the main options and the...
Read more >
Do I have to store tokens in cookies or localstorage or session?
This answer is based on the stateless approach and therefore it doesn't talk about the traditional session management.
Read more >
Questions on rigidity of token-based session storage ... - GitHub
Storage for token-based sessions comes up in the first place because of two persistence needs: Session retention across page refreshes; Session ...
Read more >
Storing Auth0 tokens in session storage instead of local storage
Tokens stored in memory won't be available in new tabs, and if the session is set to non-persisting, silent auth won't log the...
Read more >
Local Storage Versus Cookies: Which to Use to Securely ...
Web applications need to store tokens to help manage user sessions. Because the browser/server relationship is “stateless,” every request would ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found