AadTokenProvider class

This class allows a developer to obtain OAuth2 tokens from Azure AD.

OAuth2 tokens are used to authenticate the user from the SharePoint page to other services such as PowerBI, Sway, Exchange, Yammer, etc.

Remarks

This class is marked as @sealed. Subclasses should not extend it.

The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the AadTokenProvider class.

Methods

getToken(resourceEndpoint, options)

Fetches the AAD OAuth2 token for a resource if the user that's currently logged in has access to that resource.

The OAuth2 token should not be cached by the caller since it is already cached by the method itself.

getToken(resourceEndpoint, useCachedToken)

Events

onBeforeRedirectEvent

Notifies the developer before a full page redirect occurs.

popupEvent

Notifies the developer if the logic flow would like to request a popup flow for user interaction.

tokenAcquisitionEvent

Notifies the developer when Token Acquisition requires user action.

Method Details

getToken(resourceEndpoint, options)

Fetches the AAD OAuth2 token for a resource if the user that's currently logged in has access to that resource.

The OAuth2 token should not be cached by the caller since it is already cached by the method itself.

getToken(resourceEndpoint: string, options?: IGetTokenOptions): Promise<string>;

Parameters

resourceEndpoint

string

the resource for which the token should be obtained

Returns

Promise<string>

A promise that will be fulfilled with the token or that will reject with an error message

getToken(resourceEndpoint, useCachedToken)

getToken(resourceEndpoint: string, useCachedToken?: boolean): Promise<string>;

Parameters

resourceEndpoint

string

useCachedToken

boolean

Returns

Promise<string>

Event Details

onBeforeRedirectEvent

Notifies the developer before a full page redirect occurs.

readonly onBeforeRedirectEvent: SPEvent<BeforeRedirectEventArgs>;

Event Type

popupEvent

Notifies the developer if the logic flow would like to request a popup flow for user interaction.

readonly popupEvent: SPEvent<PopupEventArgs>;

Event Type

tokenAcquisitionEvent

Notifies the developer when Token Acquisition requires user action.

get tokenAcquisitionEvent(): SPEvent<TokenAcquisitionEventArgs>;

Event Type