@azure/msal-react package
Interfaces
| IMsalContext |
Type Aliases
| AccountIdentifiers | |
| AuthenticatedTemplateProps | |
| MsalAuthenticationProps | |
| MsalAuthenticationResult | |
| MsalProviderProps | |
| SetComplement | |
| SetDifference | |
| Subtract | |
| UnauthenticatedTemplateProps | |
| WithMsalProps |
Functions
Variables
| Msal |
|
| Msal |
|
| version |
Function Details
AuthenticatedTemplate(PropsWithChildrenInfo, "homeAccountId" | "localAccountId" | "username">>>)
Renders child components if user is authenticated
function AuthenticatedTemplate(props: PropsWithChildren>>): React.ReactElement | null
Parameters
- props
-
PropsWithChildren
AccountInfo, "homeAccountId" | "localAccountId" | "username">>>
Returns
React.ReactElement | null
MsalAuthenticationTemplate(PropsWithChildrenInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | PartialAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>)
Attempts to authenticate user if not already authenticated, then renders child components
function MsalAuthenticationTemplate(props: PropsWithChildren> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>): React.ReactElement | null
Parameters
- props
-
PropsWithChildren
AccountInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial >, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>
Returns
React.ReactElement | null
MsalProvider(PropsWithChildren<{ instance: IPublicClientApplication }>)
MSAL context provider component. This must be rendered above any other components that use MSAL.
function MsalProvider(__namedParameters: PropsWithChildren<{ instance: IPublicClientApplication }>): React.ReactElement
Parameters
- __namedParameters
-
PropsWithChildren<{ instance: IPublicClientApplication }>
Returns
UnauthenticatedTemplate(PropsWithChildrenInfo, "homeAccountId" | "localAccountId" | "username">>>)
Renders child components if user is unauthenticated
function UnauthenticatedTemplate(props: PropsWithChildren>>): React.ReactElement | null
Parameters
- props
-
PropsWithChildren
AccountInfo, "homeAccountId" | "localAccountId" | "username">>>
Returns
React.ReactElement | null
useAccount(PartialInfo, "homeAccountId" | "localAccountId" | "username">>)
Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
function useAccount(accountIdentifiers?: Partial>): AccountInfo | null
Parameters
- accountIdentifiers
-
Partial
AccountInfo, "homeAccountId" | "localAccountId" | "username">>
Returns
AccountInfo | null
useIsAuthenticated(PartialInfo, "homeAccountId" | "localAccountId" | "username">>)
Returns whether or not a user is currently signed-in. Optionally provide 1 or more accountIdentifiers to determine if a specific user is signed-in
function useIsAuthenticated(matchAccount?: Partial>): boolean
Parameters
- matchAccount
-
Partial
AccountInfo, "homeAccountId" | "localAccountId" | "username">>
Returns
boolean
useMsal()
useMsalAuthentication(InteractionType, PopupRequest | RedirectRequest | PartialAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, PartialInfo, "homeAccountId" | "localAccountId" | "username">>)
If a user is not currently signed in this hook invokes a login. Failed logins can be retried using the login callback returned. If a user is currently signed in this hook attempts to acquire a token. Subsequent token requests can use the acquireToken callback returned. Optionally provide a request object to be used in the login/acquireToken call. Optionally provide a specific user that should be logged in.
function useMsalAuthentication(interactionType: InteractionType, authenticationRequest?: PopupRequest | RedirectRequest | Partial>, accountIdentifiers?: Partial>): MsalAuthenticationResult
Parameters
- interactionType
- InteractionType
- authenticationRequest
-
PopupRequest | RedirectRequest | Partial
CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>
- accountIdentifiers
-
Partial
AccountInfo, "homeAccountId" | "localAccountId" | "username">>
Returns
withMsal(ComponentType)
(Component )
Higher order component wraps provided component with msal by injecting msal context values into the component's props
function withMsal(Component: ComponentType
): FunctionComponent>
Parameters
- Component
-
ComponentType
Returns
FunctionComponent<Subtract
WithMsalProps>>
Variable Details
MsalConsumer
MsalContext
version
version: "3.0.29"
Type
"3.0.29"