UserAgentApplication class
UserAgentApplication class Object Instance that the developer can use to make loginXX OR acquireTokenXX functions
Constructors
User |
Properties
authority | Method to manage the authority URL. |
Methods
acquire |
Use when you want to obtain an access_token for your API via opening a popup window in the user's browser |
acquire |
Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint. |
acquire |
Use this function to obtain a token before every call to the API / resource provider MSAL return's a cached token when available Or it send's a request to the STS to obtain a new token using a hidden iframe. |
get |
Returns the signed in account (the account object is created at the time of successful login) or null when no state is found |
get |
Use to get a list of unique accounts in MSAL cache based on homeAccountIdentifier. |
get |
Get the current authority instance from the MSAL configuration object |
get |
Use to get the current Configuration object in MSAL |
get |
Return boolean flag to developer to help inform if login is in progress |
get |
Use to get the post logout redirect uri configured in MSAL or null. Evaluates postLogoutredirectUri if its a function, otherwise simply returns its value. |
get |
Use to get the redirect uri configured in MSAL or null. Evaluates redirectUri if its a function, otherwise simply returns its value. |
login |
Use when initiating the login process via opening a popup window in the user's browser |
login |
Use when initiating the login process by redirecting the user's browser to the authorization endpoint. |
logout(string) | Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
Default behaviour is to redirect the user to |
set |
Sets the logger callback. |
sso |
API interfacing idToken request when applications already have a session/hint acquired by authorization client applications |
url |
Public API to verify if the URL contains the hash with known properties |
Constructor Details
UserAgentApplication(Configuration)
new UserAgentApplication(configuration: Configuration)
Parameters
- configuration
- Configuration
object for the MSAL UserAgentApplication instance
Property Details
authority
Method to manage the authority URL.
authority: string
Property Value
string
Method Details
acquireTokenPopup(AuthenticationParameters)
Use when you want to obtain an access_token for your API via opening a popup window in the user's browser
function acquireTokenPopup(userRequest: AuthenticationParameters): Promise<AuthResponse>
Parameters
- userRequest
- AuthenticationParameters
Returns
Promise<AuthResponse>
- a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the AuthResponse object
acquireTokenRedirect(AuthenticationParameters)
Use when you want to obtain an access_token for your API by redirecting the user's browser window to the authorization endpoint.
function acquireTokenRedirect(userRequest: AuthenticationParameters)
Parameters
- userRequest
- AuthenticationParameters
acquireTokenSilent(AuthenticationParameters)
Use this function to obtain a token before every call to the API / resource provider MSAL return's a cached token when available Or it send's a request to the STS to obtain a new token using a hidden iframe.
function acquireTokenSilent(userRequest: AuthenticationParameters): Promise<AuthResponse>
Parameters
- userRequest
- AuthenticationParameters
Returns
Promise<AuthResponse>
- a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the AuthResponse object
getAccount()
Returns the signed in account (the account object is created at the time of successful login) or null when no state is found
function getAccount(): Account
Returns
- the account object stored in MSAL
getAllAccounts()
Use to get a list of unique accounts in MSAL cache based on homeAccountIdentifier.
function getAllAccounts(): Array<Account>
Returns
Array<Account>
getAuthorityInstance()
Get the current authority instance from the MSAL configuration object
function getAuthorityInstance(): Authority
Returns
Authority
authority instance
getCurrentConfiguration()
Use to get the current Configuration object in MSAL
function getCurrentConfiguration(): Configuration
Returns
getLoginInProgress()
Return boolean flag to developer to help inform if login is in progress
function getLoginInProgress(): boolean
Returns
boolean
true/false
getPostLogoutRedirectUri()
Use to get the post logout redirect uri configured in MSAL or null. Evaluates postLogoutredirectUri if its a function, otherwise simply returns its value.
function getPostLogoutRedirectUri(): string
Returns
string
post logout redirect URL
getRedirectUri(string)
Use to get the redirect uri configured in MSAL or null. Evaluates redirectUri if its a function, otherwise simply returns its value.
function getRedirectUri(reqRedirectUri?: string): string
Parameters
- reqRedirectUri
-
string
Returns
string
redirect URL
loginPopup(AuthenticationParameters)
Use when initiating the login process via opening a popup window in the user's browser
function loginPopup(userRequest?: AuthenticationParameters): Promise<AuthResponse>
Parameters
- userRequest
- AuthenticationParameters
Returns
Promise<AuthResponse>
- a promise that is fulfilled when this function has completed, or rejected if an error was raised. Returns the AuthResponse object
loginRedirect(AuthenticationParameters)
Use when initiating the login process by redirecting the user's browser to the authorization endpoint.
function loginRedirect(userRequest?: AuthenticationParameters)
Parameters
- userRequest
- AuthenticationParameters
logout(string)
Use to log out the current user, and redirect the user to the postLogoutRedirectUri.
Default behaviour is to redirect the user to window.location.href
.
function logout(correlationId?: string)
Parameters
- correlationId
-
string
setLogger(Logger)
Sets the logger callback.
function setLogger(logger: Logger)
Parameters
- logger
- Logger
Logger callback
ssoSilent(AuthenticationParameters)
API interfacing idToken request when applications already have a session/hint acquired by authorization client applications
function ssoSilent(request: AuthenticationParameters): Promise<AuthResponse>
Parameters
- request
- AuthenticationParameters
Returns
Promise<AuthResponse>
urlContainsHash(string)
Public API to verify if the URL contains the hash with known properties
function urlContainsHash(hash: string): boolean
Parameters
- hash
-
string
Returns
boolean