MSAL in Storybook
See original GitHub issueCore Library
MSAL.js v2 (@azure/msal-browser)
Core Library Version
2.19.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
1.1.1
Description
I’m Trying to set up MSAL in Storybook using a decorator, https://storybook.js.org/docs/react/writing-stories/decorators
It works fine on pageload and if refresh the page, but if i click between the stories I can see that “inProgress” is “startup” and nothing else happens.
I have tried with different configurations for cache, but to no avail.
Anyone got any tips or have done this themself?
I reckon it is something on Storybooks side and how they handle routing as it the same configration i use for the other apps and they work fine.
I dont want to add MSALProvider for each story
MSAL Configuration
auth: {
clientId: xxx,
authority: xxx,
redirectUri: '/',
},
cache: {
secureCookies: true,
cacheLocation: 'localStorage', // This configures where your cache will be stored
storeAuthStateInCookie: true, // Set this to "true" if you are having issues on IE11 or Edge
},
Relevant Code Snippets
./storybook/preview.js
const withMSALProvider = (Story) => {
return (
<MsalProvider instance={publicClientApplication}>
<MsalAuthenticationTemplate
interactionType={InteractionType.Popup}
loadingComponent={InProgressComponent}
errorComponent={ErrorComponent}
>
<Story />
</MsalAuthenticationTemplate>
<UnauthenticatedTemplate>
<LoggInn />
</UnauthenticatedTemplate>
</MsalProvider>
);
};
export const decorators = [withMSALProvider];
Identity Provider
Azure AD / MSA
Source
External (Customer)
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Auth - Page ⋅ Storybook - Introduction
Provides the ability to restrict contents based on clientId (e.g. restrict content if the user is not authenticated against clientId). For base usage,...
Read more >Add Auth to a Storybook project - Stack Overflow
I'd want to use authentication in my Storybook project (my preferred auth provider being Auth0). Is there any add-on that could help me...
Read more >Getting started / Recommended libraries - Page ⋅ Storybook
microsoft-authentication-library-for-js msal-react is a library which provides Azure Active Directory Library (ADAL) support for React.
Read more >Overview - Page ⋅ Storybook
Uses msal-browser to sign in users and acquire tokens in Microsoft Teams tabs. Supports Single Sign-On with custom backend. TeamsFx, Use the TeamsFx...
Read more >Testing component interactions - Storybook - Medium
This is an email from Storybook news, a newsletter by Storybook. ... Azure AD authentication in angular using MSAL angular v2 library.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue will be fixed by the linked PR. Thanks for bringing this to our attention!
I was able to workaround this issue with this code.
@tnorling Thanks for your help.