Skip to content

Commit

Permalink
[Outlook] - Update Outlook NAA sample to use standard public client a…
Browse files Browse the repository at this point in the history
…s fallback. (#866)

* use standard public client application in fallback path

* Update Samples/auth/Outlook-Add-in-SSO-NAA/src/taskpane/fallback/fallbackauthdialog.ts

Co-authored-by: Alex Jerabek <[email protected]>

* Update Samples/auth/Outlook-Add-in-SSO-NAA/src/taskpane/fallback/dialog.html

Co-authored-by: Alex Jerabek <[email protected]>

* Update Samples/auth/Outlook-Add-in-SSO-NAA/src/taskpane/taskpane.html

Co-authored-by: Alex Jerabek <[email protected]>

---------

Co-authored-by: Alex Jerabek <[email protected]>
  • Loading branch information
codexeon and AlexJerabek authored Oct 8, 2024
1 parent 7ef6850 commit 02e6400
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<title>Dialog</title>

<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.debug.js"></script>
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>
</head>

<body></body>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

/* global Office, window, URLSearchParams */

import { AuthenticationResult, IPublicClientApplication } from "@azure/msal-browser";
import { getTokenRequest, ensurePublicClient } from "../msalcommon";
import {
AuthenticationResult,
createStandardPublicClientApplication,
IPublicClientApplication,
} from "@azure/msal-browser";
import { getTokenRequest } from "../msalcommon";
import { createLocalUrl } from "../util";
import { defaultScopes } from "../msalconfig";
import { defaultScopes, msalConfig } from "../msalconfig";
import type { AuthDialogResult } from "../authConfig";

// read querystring parameter
Expand All @@ -32,7 +36,8 @@ async function returnResult(publicClientApp: IPublicClientApplication, authResul
}

export async function initializeMsal() {
const publicClientApp = await ensurePublicClient();
// Use standard Public Client instead of nested because this is a fallback path when nested app authentication isn't available.
const publicClientApp = await createStandardPublicClientApplication(msalConfig);
try {
if (getQueryParameter("logout") === "1") {
await publicClientApp.logoutRedirect({ postLogoutRedirectUri: createLocalUrl("dialog.html?close=1") });
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<title>Contoso Task Pane Add-in</title>

<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/beta/hosted/office.js"></script>
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1.1/hosted/office.js"></script>

<!-- For Office UI Fabric Core, go to https://aka.ms/office-ui-fabric to learn more. -->
<link
Expand Down
6 changes: 0 additions & 6 deletions Samples/auth/Outlook-Add-in-SSO-NAA/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ module.exports = async (env, options) => {
polyfill: ["core-js/stable", "regenerator-runtime/runtime"],
taskpane: ["./src/taskpane/taskpane.ts", "./src/taskpane/taskpane.html"],
dialog: ["./src/taskpane/fallback/fallbackauthdialog.ts"],
signoutdialog: ["./src/taskpane/fallback/signoutdialog.ts"],
},
output: {
clean: true,
Expand Down Expand Up @@ -70,11 +69,6 @@ module.exports = async (env, options) => {
template: "./src/taskpane/fallback/dialog.html",
chunks: ["dialog"],
}),
new HtmlWebpackPlugin({
filename: "signoutdialog.html",
template: "./src/taskpane/fallback/dialog.html",
chunks: ["signoutdialog"],
}),
new CopyWebpackPlugin({
patterns: [
{
Expand Down

0 comments on commit 02e6400

Please sign in to comment.