mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-02 19:43:20 +08:00
Add SSO APIs to office-js (#18848)
* Added SSO APIs to office.js * corrected type in test * New property in AuthOptions type
This commit is contained in:
committed by
Mohamed Hegazy
parent
b820a56634
commit
35cbdc2020
27
types/office-js/index.d.ts
vendored
27
types/office-js/index.d.ts
vendored
@@ -105,6 +105,7 @@ declare namespace Office {
|
||||
value: any;
|
||||
}
|
||||
export interface Context {
|
||||
auth: Auth;
|
||||
contentLanguage: string;
|
||||
displayLanguage: string;
|
||||
license: string;
|
||||
@@ -184,6 +185,32 @@ declare namespace Office {
|
||||
*/
|
||||
displayInIframe?: boolean
|
||||
}
|
||||
export interface Auth {
|
||||
/**
|
||||
* Obtains an access token from AAD V 2.0 endpoint to grant the Office host application access to the add-in's web application.
|
||||
* @param options Optional. Accepts an AuthOptions object to define sign-on behaviors.
|
||||
* @param callback Optional. Accepts a callback method to handle the token acquisition attempt. If AsyncResult.status is "succeeded", then AsyncResult.value is the raw AAD v. 2.0-formatted access token.
|
||||
*/
|
||||
getAccessTokenAsync(options?: AuthOptions, callback?: (result: AsyncResult) => void): void;
|
||||
}
|
||||
export interface AuthOptions {
|
||||
/**
|
||||
* Optional. Causes Office to display the add-in consent experience. Useful if the add-in's Azure permissions have changed or if the user's consent has been revoked.
|
||||
*/
|
||||
forceConsent?: boolean,
|
||||
/**
|
||||
* Optional. Prompts the user to add (or to switch if already added) his or her Office account.
|
||||
*/
|
||||
forceAddAccount?: boolean,
|
||||
/**
|
||||
* Optional. 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 be used with the authChallenge option.
|
||||
*/
|
||||
authChallenge?: string
|
||||
/**
|
||||
* Optional. A user-defined item of any type that is returned in the AsyncResult object without being altered.
|
||||
*/
|
||||
asyncContext?: any
|
||||
}
|
||||
export interface OfficeTheme {
|
||||
bodyBackgroundColor: string;
|
||||
bodyForegroundColor: string;
|
||||
|
||||
@@ -249,3 +249,19 @@ function test_word() {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function test_shared() {
|
||||
Office.context.auth.getAccessTokenAsync({ forceConsent: false },
|
||||
function (result) {
|
||||
if (result.status === Office.AsyncResultStatus.Succeeded) {
|
||||
// result.value is the raw access token
|
||||
console.log(result.value)
|
||||
}
|
||||
else {
|
||||
console.log("Code: " + result.error.code);
|
||||
console.log("Message: " + result.error.message);
|
||||
console.log("name: " + result.error.name);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user