@azure/msal-react package
Classes
ReactAuthError |
Interfaces
IMsalContext |
Type Aliases
Functions
Msal |
MSAL context provider component. This must be rendered above any other components that use MSAL. |
Authenticated |
Renders child components if user is authenticated |
Msal |
Attempts to authenticate user if not already authenticated, then renders child components |
Unauthenticated |
Renders child components if user is unauthenticated |
use |
Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in |
use |
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 |
use |
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. |
account |
Helper function to determine whether 2 arrays are equal Used to avoid unnecessary state updates |
get |
|
get |
Function Details
MsalProvider({ children: any, instance: any })
MSAL context provider component. This must be rendered above any other components that use MSAL.
function MsalProvider(__namedParameters: { children: any, instance: any }): React.ReactElement
Parameters
- __namedParameters
-
{ children: any, instance: any }
Returns
AuthenticatedTemplate({ children: any, homeAccountId: any, localAccountId: any, username: any })
Renders child components if user is authenticated
function AuthenticatedTemplate(__namedParameters: { children: any, homeAccountId: any, localAccountId: any, username: any }): React.ReactElement | null
Parameters
- __namedParameters
-
{ children: any, homeAccountId: any, localAccountId: any, username: any }
Returns
React.ReactElement | null
MsalAuthenticationTemplate({ ErrorComponent: any, LoadingComponent: any, authenticationRequest: any, children: any, homeAccountId: any, interactionType: any, localAccountId: any, username: any })
Attempts to authenticate user if not already authenticated, then renders child components
function MsalAuthenticationTemplate(__namedParameters: { ErrorComponent: any, LoadingComponent: any, authenticationRequest: any, children: any, homeAccountId: any, interactionType: any, localAccountId: any, username: any }): React.ReactElement | null
Parameters
- __namedParameters
-
{ ErrorComponent: any, LoadingComponent: any, authenticationRequest: any, children: any, homeAccountId: any, interactionType: any, localAccountId: any, username: any }
Returns
React.ReactElement | null
UnauthenticatedTemplate({ children: any, homeAccountId: any, localAccountId: any, username: any })
Renders child components if user is unauthenticated
function UnauthenticatedTemplate(__namedParameters: { children: any, homeAccountId: any, localAccountId: any, username: any }): React.ReactElement | null
Parameters
- __namedParameters
-
{ children: any, homeAccountId: any, localAccountId: any, username: any }
Returns
React.ReactElement | null
useAccount(AccountIdentifiers)
Given 1 or more accountIdentifiers, returns the Account object if the user is signed-in
function useAccount(accountIdentifiers?: AccountIdentifiers): AccountInfo | null
Parameters
- accountIdentifiers
- AccountIdentifiers
Returns
AccountInfo | null
useIsAuthenticated(AccountIdentifiers)
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?: AccountIdentifiers): boolean
Parameters
- matchAccount
- AccountIdentifiers
Returns
boolean
useMsalAuthentication(InteractionType, PopupRequest | RedirectRequest | SsoSilentRequest, AccountIdentifiers)
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 | SsoSilentRequest, accountIdentifiers?: AccountIdentifiers): MsalAuthenticationResult
Parameters
- interactionType
-
InteractionType
- authenticationRequest
-
PopupRequest | RedirectRequest | SsoSilentRequest
- accountIdentifiers
- AccountIdentifiers
Returns
accountArraysAreEqual(Array<AccountIdentifiers>, Array<AccountIdentifiers>)
Helper function to determine whether 2 arrays are equal Used to avoid unnecessary state updates
function accountArraysAreEqual(arrayA: Array<AccountIdentifiers>, arrayB: Array<AccountIdentifiers>): boolean
Parameters
- arrayA
-
Array<AccountIdentifiers>
- arrayB
-
Array<AccountIdentifiers>
Returns
boolean
getAccountByIdentifiers(AccountInfo[], AccountIdentifiers)
function getAccountByIdentifiers(allAccounts: AccountInfo[], accountIdentifiers: AccountIdentifiers): AccountInfo | null
Parameters
- allAccounts
-
AccountInfo[]
- accountIdentifiers
- AccountIdentifiers
Returns
AccountInfo | null
getChildrenOrFunction<T>(React.ReactNode | FaaCFunction, T)
function getChildrenOrFunction<T>(children: React.ReactNode | FaaCFunction, args: T): React.ReactNode
Parameters
- children
-
React.ReactNode | FaaCFunction
- args
-
T