Implement a custom storage provider
mainBy default, the library uses sessionStorage. To use a different mechanism like localStorage or cookies, implement the AbstractSecurityStorage interface. Your implementation must include the following methods:
read(key: string): string | nullwrite(key: string, value: string): voidremove(key: string): voidclear(): void
import { AbstractSecurityStorage } from 'angular-auth-oidc-client';
@Injectable()
export class MyStorageService implements AbstractSecurityStorage {
read(key: string): string | null {
return localStorage.getItem(key);
}
write(key: string, value: string): void {
localStorage.setItem(key, value);
}
remove(key: string): void {
localStorage.removeItem(key);
}
clear(): void {
localStorage.clear();
}
}