Okta-auth-js custom storageProvider not calling setItem

For my OktaAuth instance I am setting the following option for storageManager.token.storageProvider in OktaAuthOptions. The okta-token-storage key is being created in localStorage but I don’t know how. I see the console log message for the getItem but not setItem. Any idea why the setItem function is not being called?

export const browserStorageProvider = {
  getItem: (key: string) => {console.log(`getItem: ${key}`); return localStorage.getItem(key)},
  setItem: (key: string, val: any) => {
    console.log(`setItem: ${key} to ${val}`);
    localStorage.setItem(key, val);
  },
  removeItem: (key: string) => localStorage.removeItem(key)
};

I figured it out, was my error. I actually have a service layer that provides the OktaAuthOptions object in order to dynamically set values and then when I create the OktaAuth object I am hand picking the config config parameters from my service and was not assigning storageManager


  externalAuthService = new OktaAuth({
    clientId: this.oktaConfigService.oktaConfig.clientId,
    issuer: this.oktaConfigService.oktaConfig.issuer,
    redirectUri: this.oktaConfigService.oktaConfig.redirectUri,
    pkce: this.oktaConfigService.oktaConfig.pkce,
    tokenManager: this.oktaConfigService.oktaConfig.tokenManager,
    storageManager: this.oktaConfigService.oktaConfig.storageManager
  });
1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.