@azure/msal-react package

Gränssnitt

IMsalContext

Funktioner

AuthenticatedTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>)

Renderar underordnade komponenter om användaren autentiseras

MsalAuthenticationTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>)

Försöker autentisera användaren om den inte redan har autentiserats och återger sedan underordnade komponenter

MsalProvider(PropsWithChildren<{ instance: IPublicClientApplication }>)

MSAL-kontextproviderkomponent. Detta måste återges ovanför andra komponenter som använder MSAL.

UnauthenticatedTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>)

Renderar underordnade komponenter om användaren inte autentiseras

useAccount(Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Givet 1 eller flera accountIdentifiers returnerar kontoobjektet om användaren är inloggad

useIsAuthenticated(Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Returnerar om en användare för närvarande är inloggad eller inte. Alternativt kan du ange 1 eller flera accountIdentifiers för att avgöra om en specifik användare är inloggad

useMsal()

Returnerar Msal Context-värden

useMsalAuthentication(InteractionType, PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Om en användare inte är inloggad i den här kroken anropas en inloggning. Misslyckade inloggningar kan göras om med hjälp av återanropet för inloggning som returneras. Om en användare för närvarande är inloggad i den här kroken försöker hämta en token. Efterföljande tokenbegäranden kan använda återanropet acquireToken returnerade. Du kan också ange ett begärandeobjekt som ska användas i inloggnings-/acquireToken-anropet. Du kan också ange en specifik användare som ska vara inloggad.

withMsal<P>(ComponentType<P>)

Högre orderkomponent omsluter den tillhandahållna komponenten med msal genom att mata in msal-kontextvärden i komponentens rekvisita

Funktionsinformation

AuthenticatedTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>)

Renderar underordnade komponenter om användaren autentiseras

function AuthenticatedTemplate(props: PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>): React.ReactElement | null

Parametrar

props

PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>

Returer

React.ReactElement | null

MsalAuthenticationTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>)

Försöker autentisera användaren om den inte redan har autentiserats och återger sedan underordnade komponenter

function MsalAuthenticationTemplate(props: PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>): React.ReactElement | null

Parametrar

props

PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">> & { authenticationRequest?: PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, errorComponent?: any, interactionType: InteractionType, loadingComponent?: any }>

Returer

React.ReactElement | null

MsalProvider(PropsWithChildren<{ instance: IPublicClientApplication }>)

MSAL-kontextproviderkomponent. Detta måste återges ovanför andra komponenter som använder MSAL.

function MsalProvider(__namedParameters: PropsWithChildren<{ instance: IPublicClientApplication }>): React.ReactElement

Parametrar

__namedParameters

PropsWithChildren<{ instance: IPublicClientApplication }>

Returer

React.ReactElement

UnauthenticatedTemplate(PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>)

Renderar underordnade komponenter om användaren inte autentiseras

function UnauthenticatedTemplate(props: PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>): React.ReactElement | null

Parametrar

props

PropsWithChildren<Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>>

Returer

React.ReactElement | null

useAccount(Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Givet 1 eller flera accountIdentifiers returnerar kontoobjektet om användaren är inloggad

function useAccount(accountIdentifiers?: Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>): AccountInfo | null

Parametrar

accountIdentifiers

Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>

Returer

AccountInfo | null

useIsAuthenticated(Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Returnerar om en användare för närvarande är inloggad eller inte. Alternativt kan du ange 1 eller flera accountIdentifiers för att avgöra om en specifik användare är inloggad

function useIsAuthenticated(matchAccount?: Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>): boolean

Parametrar

matchAccount

Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>

Returer

boolean

useMsal()

Returnerar Msal Context-värden

function useMsal(): IMsalContext

Returer

useMsalAuthentication(InteractionType, PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>)

Om en användare inte är inloggad i den här kroken anropas en inloggning. Misslyckade inloggningar kan göras om med hjälp av återanropet för inloggning som returneras. Om en användare för närvarande är inloggad i den här kroken försöker hämta en token. Efterföljande tokenbegäranden kan använda återanropet acquireToken returnerade. Du kan också ange ett begärandeobjekt som ska användas i inloggnings-/acquireToken-anropet. Du kan också ange en specifik användare som ska vara inloggad.

function useMsalAuthentication(interactionType: InteractionType, authenticationRequest?: PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>, accountIdentifiers?: Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>): MsalAuthenticationResult

Parametrar

interactionType
InteractionType
authenticationRequest

PopupRequest | RedirectRequest | Partial<Omit<CommonAuthorizationUrlRequest, "responseMode" | "earJwk" | "codeChallenge" | "codeChallengeMethod" | "requestedClaimsHash" | "platformBroker">>

accountIdentifiers

Partial<Pick<AccountInfo, "homeAccountId" | "localAccountId" | "username">>

Returer

withMsal<P>(ComponentType<P>)

Högre orderkomponent omsluter den tillhandahållna komponenten med msal genom att mata in msal-kontextvärden i komponentens rekvisita

function withMsal<P>(Component: ComponentType<P>): FunctionComponent<Subtract<P, WithMsalProps>>

Parametrar

Component

ComponentType<P>

Returer

FunctionComponent<Subtract<P, WithMsalProps>>

Variabelinformation

MsalConsumer

MsalConsumer: React.Consumer<IMsalContext>

Typ

React.Consumer<IMsalContext>

MsalContext

MsalContext: React.Context<IMsalContext>

Typ

React.Context<IMsalContext>

version

version: "3.0.29"

Typ

"3.0.29"