IAadTokenProvider interface
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
AadTokenProvider is replacing the /_api.SP.OAuth.Token/Acquire endpoint for authentication with ADAL.js. At some point in the near future, when Azure AD v2.0 can support the same scenarios as the original version, we will switch to MSAL.
Methods
get |
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. An example of a resourceEndpoint would be https://sdfpilot.outlook.com |
get |
Events
on |
Notifies the developer before a full page redirect occurs. |
popup |
Notifies the developer before a full page redirect occurs. |
token |
Notifies the developer when Token Acquistion 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.
An example of a resourceEndpoint would be https://sdfpilot.outlook.com
getToken(resourceEndpoint: string, options?: IGetTokenOptions): Promise<string>;
Parameters
- resourceEndpoint
-
string
the resource for which the token should be obtained
- options
- IGetTokenOptions
Returns
Promise<string>
A promise that will be fullfiled 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<IBeforeRedirectEventArgs>;
Event Type
popupEvent
Notifies the developer before a full page redirect occurs.
readonly popupEvent: SPEvent<IPopupEventArgs>;
Event Type
tokenAcquisitionEvent
Notifies the developer when Token Acquistion requires user action.
readonly tokenAcquisitionEvent: SPEvent<ITokenAcquisitionEventArgs>;