Editar

Compartilhar via


IPublicClientApplication interface

Interface for the PublicClientApplication class defining the public API signatures

Methods

acquireTokenByCode(AuthorizationCodeRequest)

Acquires a token by exchanging the authorization code received from the first step of OAuth 2.0 Authorization Code Flow

acquireTokenByDeviceCode(DeviceCodeRequest)

Acquires a token from the authority using OAuth2.0 device code flow

acquireTokenByRefreshToken(RefreshTokenRequest)

Acquires a token by exchanging the refresh token provided for a new set of tokens

acquireTokenByUsernamePassword(UsernamePasswordRequest)

Acquires tokens with password grant by exchanging client applications username and password for credentials

acquireTokenInteractive(InteractiveRequest)

Acquires a token interactively

acquireTokenSilent(SilentFlowRequest)

Acquires a token silently when a user specifies the account the token is requested for

clearCache()

Clear the cache

getAllAccounts()

Gets all cached accounts

getAuthCodeUrl(AuthorizationUrlRequest)

Creates the URL of the authorization request

getLogger()

Returns the logger instance

getTokenCache()

Gets the token cache for the application

setLogger(Logger)

Replaces the default logger set in configurations with new Logger with new configurations

signOut(SignOutRequest)

Removes cache artifacts associated with the given account

Method Details

acquireTokenByCode(AuthorizationCodeRequest)

Acquires a token by exchanging the authorization code received from the first step of OAuth 2.0 Authorization Code Flow

function acquireTokenByCode(request: AuthorizationCodeRequest): Promise<AuthenticationResult>

Parameters

Returns

acquireTokenByDeviceCode(DeviceCodeRequest)

Acquires a token from the authority using OAuth2.0 device code flow

function acquireTokenByDeviceCode(request: DeviceCodeRequest): Promise<null | AuthenticationResult>

Parameters

Returns

Promise<null | AuthenticationResult>

acquireTokenByRefreshToken(RefreshTokenRequest)

Acquires a token by exchanging the refresh token provided for a new set of tokens

function acquireTokenByRefreshToken(request: RefreshTokenRequest): Promise<null | AuthenticationResult>

Parameters

Returns

Promise<null | AuthenticationResult>

acquireTokenByUsernamePassword(UsernamePasswordRequest)

Warning

This API is now deprecated.

  • Use a more secure flow instead

Acquires tokens with password grant by exchanging client applications username and password for credentials

function acquireTokenByUsernamePassword(request: UsernamePasswordRequest): Promise<null | AuthenticationResult>

Parameters

Returns

Promise<null | AuthenticationResult>

acquireTokenInteractive(InteractiveRequest)

Acquires a token interactively

function acquireTokenInteractive(request: InteractiveRequest): Promise<AuthenticationResult>

Parameters

Returns

acquireTokenSilent(SilentFlowRequest)

Acquires a token silently when a user specifies the account the token is requested for

function acquireTokenSilent(request: SilentFlowRequest): Promise<AuthenticationResult>

Parameters

Returns

clearCache()

Clear the cache

function clearCache()

getAllAccounts()

Gets all cached accounts

function getAllAccounts(): Promise<AccountInfo[]>

Returns

Promise<AccountInfo[]>

getAuthCodeUrl(AuthorizationUrlRequest)

Creates the URL of the authorization request

function getAuthCodeUrl(request: AuthorizationUrlRequest): Promise<string>

Parameters

Returns

Promise<string>

getLogger()

Returns the logger instance

function getLogger(): Logger

Returns

getTokenCache()

Gets the token cache for the application

function getTokenCache(): TokenCache

Returns

setLogger(Logger)

Replaces the default logger set in configurations with new Logger with new configurations

function setLogger(logger: Logger)

Parameters

logger
Logger

signOut(SignOutRequest)

Removes cache artifacts associated with the given account

function signOut(request: SignOutRequest): Promise<void>

Parameters

request
SignOutRequest

Returns

Promise<void>