office-js, office-js-preview, switch to new getAccessToken API (#47466)

This commit is contained in:
Rick Kirkham 2020-09-10 18:21:41 -07:00 committed by GitHub
parent 56df0fc769
commit 804f1f68a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 6 deletions

View File

@ -1195,8 +1195,10 @@ declare namespace Office {
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
*
* @deprecated Use Office.auth.getAccessToken instead.
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
*
* @remarks
*
* **Hosts**: Excel, OneNote, Outlook, PowerPoint, Word
@ -1216,6 +1218,8 @@ declare namespace Office {
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
*
* @deprecated Use `Office.auth.getAccessToken` instead.
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
* @remarks
@ -1231,9 +1235,28 @@ declare namespace Office {
* If `AsyncResult.status` is "succeeded", then `AsyncResult.value` is the raw AAD v. 2.0-formatted access token.
*/
getAccessTokenAsync(callback?: (result: AsyncResult<string>) => void): void;
/**
* Calls the Azure Active Directory V 2.0 endpoint to get an access token to your add-in's web application. Enables add-ins to identify users.
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
* This API requires a single sign-on configuration that bridges the add-in to an Azure application. Office users sign in with Organizational
* Accounts and Microsoft Accounts. Microsoft Azure returns tokens intended for both user account types to access resources in the Microsoft Graph.
*
* @remarks
*
* **Hosts**: Excel, OneNote, Outlook, PowerPoint, Word
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
* **Requirement set**: {@link https://docs.microsoft.com/office/dev/add-ins/reference/requirement-sets/identity-api-requirement-sets | IdentityAPI}
*
* @param options - Optional. Accepts an `AuthOptions` object to define sign-on behaviors.
* @returns Promise to the access token.
*/
getAccessToken(options?: AuthOptions): Promise<string>;
}
/**
* Provides options for the user experience when Office obtains an access token to the add-in from AAD v. 2.0 with the `getAccessTokenAsync` method.
* Provides options for the user experience when Office obtains an access token to the add-in from AAD v. 2.0 with the `getAccessToken` method.
*/
interface AuthOptions {
/**
@ -1266,7 +1289,7 @@ declare namespace Office {
* Causes Office to prompt the user to provide the additional factor when the tenancy being targeted by Microsoft Graph requires multifactor
* authentication. The string value identifies the type of additional factor that is required. In most cases, you won't know at development
* time whether the user's tenant requires an additional factor or what the string should be. So this option would be used in a "second try"
* call of `getAccessTokenAsync` after Microsoft Graph has sent an error requesting the additional factor and containing the string that should
* call of `getAccessToken` after Microsoft Graph has sent an error requesting the additional factor and containing the string that should
* be used with the `authChallenge` option.
*/
authChallenge?: string;

View File

@ -1124,8 +1124,10 @@ declare namespace Office {
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
*
* @deprecated Use Office.auth.getAccessToken instead.
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
*
* @remarks
*
* **Hosts**: Excel, OneNote, Outlook, PowerPoint, Word
@ -1145,6 +1147,8 @@ declare namespace Office {
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
*
* @deprecated Use `Office.auth.getAccessToken` instead.
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
* @remarks
@ -1160,9 +1164,28 @@ declare namespace Office {
* If `AsyncResult.status` is "succeeded", then `AsyncResult.value` is the raw AAD v. 2.0-formatted access token.
*/
getAccessTokenAsync(callback?: (result: AsyncResult<string>) => void): void;
/**
* Calls the Azure Active Directory V 2.0 endpoint to get an access token to your add-in's web application. Enables add-ins to identify users.
* Server-side code can use this token to access Microsoft Graph for the add-in's web application by using the
* {@link https://docs.microsoft.com/azure/active-directory/develop/active-directory-v2-protocols-oauth-on-behalf-of | "on behalf of" OAuth flow}.
* This API requires a single sign-on configuration that bridges the add-in to an Azure application. Office users sign in with Organizational
* Accounts and Microsoft Accounts. Microsoft Azure returns tokens intended for both user account types to access resources in the Microsoft Graph.
*
* @remarks
*
* **Hosts**: Excel, OneNote, Outlook, PowerPoint, Word
*
* **Important**: In Outlook, this API is not supported if the add-in is loaded in an Outlook.com or Gmail mailbox.
*
* **Requirement set**: {@link https://docs.microsoft.com/office/dev/add-ins/reference/requirement-sets/identity-api-requirement-sets | IdentityAPI}
*
* @param options - Optional. Accepts an `AuthOptions` object to define sign-on behaviors.
* @returns Promise to the access token.
*/
getAccessToken(options?: AuthOptions): Promise<string>;
}
/**
* Provides options for the user experience when Office obtains an access token to the add-in from AAD v. 2.0 with the `getAccessTokenAsync` method.
* Provides options for the user experience when Office obtains an access token to the add-in from AAD v. 2.0 with the `getAccessToken` method.
*/
interface AuthOptions {
/**
@ -1195,7 +1218,7 @@ declare namespace Office {
* Causes Office to prompt the user to provide the additional factor when the tenancy being targeted by Microsoft Graph requires multifactor
* authentication. The string value identifies the type of additional factor that is required. In most cases, you won't know at development
* time whether the user's tenant requires an additional factor or what the string should be. So this option would be used in a "second try"
* call of `getAccessTokenAsync` after Microsoft Graph has sent an error requesting the additional factor and containing the string that should
* call of `getAccessToken` after Microsoft Graph has sent an error requesting the additional factor and containing the string that should
* be used with the `authChallenge` option.
*/
authChallenge?: string;