Closed xstos closed 3 years ago
@xstos Thanks for reporting this issue. Let me see if I can repro this issue and get back to you.
-Courtney
@xstos While I don't hit the precise error you are hitting, I do hit another error and it may be related. I suspect there has been a change in the Graph API that we use for configuring the SSO application that has broken our tooling:
(node:26940) UnhandledPromiseRejectionWarning: Error: Unable to determine if user is tenant admin: Bad Request({ "error": { "code": "Request_BadRequest", "message": "Invalid object identifier 'members'.", "innerError": { "date": "2021-02-01T21:03:04", "request-id": "898cee28-1d6d-484b-9263-075dc17598f9", "client-request-id": "898cee28-1d6d-484b-9263-075dc17598f9" } } })
I will see if I can determine the problem and get a fix out for it soon
-Courtney
Cool. I'm here to test if need be :)
It looks like the API for getting the directory members has changed: https://docs.microsoft.com/en-us/graph/api/directoryrole-list-members?view=graph-rest-1.0&tabs=http. It now requires an id, so our current az rest call to ""az rest -m get -u https://graph.microsoft.com/v1.0/directoryRoles/members --headers \"Content-Type=application/json\"" is invalid as we don't specify an id.
Aha! I figured out the real crux of the problem for the issue I am seeing and that others have reported. The directory roles names have changed and they no longer use the naming convention "Company Administrator" for a tenant admin - it's now called "Global Administrator." Hence, when we try to get the id associated with "Company Administrator", we get undefined which cause subsequent configuration of the tenant admin to fail
@xstos You can try apply this very simple change in node_module\offlce-addin-sso\lib\configure.js and see if things work for you: https://github.com/OfficeDev/Office-Addin-Scripts/pull/376
No dice
i stuck a console.log to see what was in the JSON at position 3324 (pasted below).
exports.logoutAzure = logoutAzure;
function promiseExecuteCommand(cmd, returnJson = true, expectError = false) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise((resolve, reject) => {
try {
childProcess.exec(cmd, { maxBuffer: 1024 * 102400 }, (err, stdout, stderr) => __awaiter(this, void 0, void 0, function* () {
if (err && !expectError) {
reject(stderr);
}
let results = stdout;
if (results !== '' && returnJson) {
console.log(results); //<=== added
results = JSON.parse(results);
}
resolve(results);
}));
}
catch (err) {
reject(err);
}
});
});
}
It appears to be complaining about this entry
{
"DisplayName": "NTFS Undelete 3.0.20.1104",
"DisplayVersion": null,
"Publisher": "Copyright c 2015 eSupport.com All Rights Reserved",
"InstallDate": "20210111"
},
The space between eSupport.com and All is suspect. It shows up as two spaces but an online unicode detector showed it as a regular space. Not sure.
In the meantime, instead of maintaining yeoman, y'all could just create a set of empty boilerplate addins on github that people can fork off of...
The starting templates are in separate github repositories. You can clone them and start with them.
However, be sure to customize the manifest and use a unique id by running:
npx office-addin-manifest modify --guid --displayName <name>
Here are a few of them: Basic: https://github.com/OfficeDev/Office-Addin-TaskPane React: https://github.com/OfficeDev/Office-Addin-TaskPane-React SSO: https://github.com/OfficeDev/Office-Addin-TaskPane-SSO
The yo-office
branch is what is used when you run yo office
. The master
branch may have more recent changes which should work. We're constantly working to keep these templates updated.
I'd forgotten about those. My bad.
@xstos What is the the DisplayName specified in the manifest for your SSO project? I am wondering if this might be the source of the problem.
@TCourtneyOwen I don't have one? I just ran yeoman and then npm run configure-sso
and it threw the error at the top of the thread.
Oh sorry I guess it's this <DisplayName DefaultValue="SSO365"/>
The project should have a manifest in it at the root of the project - Yo Office always creates a manifest with the project. If there is no manifest, this would most surely be the root of the problem, as configure-sso uses that DisplayName when creating the SSO application in Azure:
const applicationJson: Object = await configure.createNewApplication(manifestInfo.displayName, port.toString(), userJson);
Sorry I had put it at the beginning of the thread and I assumed I'd forgotten something. It's
<DisplayName DefaultValue="SSO365"/>
It's just the default manifest after running yeoman. No extra shenanigans...
Based on the output you pasted above it would seem the issue is happening in createNewApplication, as this is the first phase of the config process, and I don't see any other output logging indicating this phase succeeded. Here's the content of the method:
export async function createNewApplication(ssoAppName: string, port: string, userJson: Object): Promise
Could you please try the following:
open node_modules\office-addin-sso\lib\configure.js and add the following before the call to promiseExecuteCommand:
console.log(`CreateNewApplication command is ${azRestCommand}`);
run "npm run configure-sso" again
capture the console output and forward in on in this thread
That way I can get a better sense if the command is somehow getting constructed improperly.
If you look in the thread above I already pinpointed the spot where it's breaking down. It didn't make it as far as createNewApplication
To further illustrate I added console trace to promiseExecuteCommand
console.log("<LOG>")
console.trace(`${cmd}`);
console.log("</LOG>")
childProcess.exec(cmd, { maxBuffer: 1024 * 102400 }, (err, stdout, stderr) => __awaiter(this, void 0,
C:\repos\xstos\apps\playground\SSO365>npm run configure-sso
> office-addin-taskpane-sso-js@0.0.0 configure-sso C:\repos\xstos\apps\playground\SSO365
> office-addin-sso configure manifest.xml
<LOG>
Trace: powershell -ExecutionPolicy Bypass -File "C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\scripts\getInstalledApps.ps1"
at console.originalConsole.<computed> [as trace] (C:\repos\xstos\apps\playground\SSO365\node_modules\diagnostic-channel-publishers\dist\src\console.pub.js:42:39)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:184:13
at new Promise (<anonymous>)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:181:16
at Generator.next (<anonymous>)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:6:71
at new Promise (<anonymous>)
at __awaiter (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:2:12)
at promiseExecuteCommand (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:180:12)
at Object.<anonymous> (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:82:47)
</LOG>
(node:23532) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token in JSON at position 3472
at JSON.parse (<anonymous>)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:192:40
at Generator.next (<anonymous>)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:6:71
at new Promise (<anonymous>)
at __awaiter (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:2:12)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:186:95
at ChildProcess.exithandler (child_process.js:299:7)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:23532) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:23532) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I actually have the newly generated yeoman addin I'm using pushed to github already in case you wan't to try it yourself...
@xstos I just tried your project at https://github.com/xstos/apps/tree/master/playground/SSO365. After updating the office-addin-sso package to v,1.0.31, the configure-sso process worked fine for me.
I am curious what version of PowerShell you are running. I am running 5.1.19041.610. To get the version open PS and run the following:
Name : ConsoleHost
Version : 5.1.19041.610
InstanceId : 2b3eea2c-519f-495d-bb91-2516454f0662
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
I also updated the version to 1.0.31
still no luck. So I added this line to configure.js and it fixed it.
results = JSON.parse(results.replace("Copyright c 2015 eSupport.com All Rights Reserved","Copyright c 2015 eSupport.com All Rights Reserved"));
I opened the weird character after eSupport.com in a hex editor and it shows unicode (U+0007) which seems broken to me.
Is it possible somebody accidentally corrupted the product list json by pasting a bad character?
So even though configure-sso
worked after my json hack, when I npm start
and browse to https://localhost:3000
I get the following. Shall I open another ticket for that?
Cannot find module 'html' Require stack: - C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\view.js - C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\application.js - C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\express.js - C:\repos\xstos\apps\playground\SSO365\node_modules\express\index.js - C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\app.js - C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\server.js - C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\commands.js - C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\cli.js - C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\cli.js
Error: Cannot find module 'html'
Require stack:
- C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\view.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\application.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\express.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\express\index.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\app.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\server.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\commands.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\cli.js
- C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\cli.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at Module.patchedRequire [as require] (C:\repos\xstos\apps\playground\SSO365\node_modules\diagnostic-channel\dist\src\patchRequire.js:14:46)
at require (internal/modules/cjs/helpers.js:88:18)
at new View (C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\view.js:81:14)
at Function.render (C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\application.js:570:12)
at ServerResponse.render (C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\response.js:1012:7)
at C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\app.js:59:21
at Layer.handle [as handle_request] (C:\repos\xstos\apps\playground\SSO365\node_modules\express\lib\router\layer.js:95:5)
I decided to run the exact same repo on my freshly installed Win10 work machine.
I didn't get that json error, but this happened instead.
C:\repos\xstos\apps\playground\SSO365>npm run configure-sso
> office-addin-taskpane-sso-js@0.0.0 configure-sso C:\repos\xstos\apps\playground\SSO365
> office-addin-sso configure manifest.xml
Opening browser for authentication to Azure. Enter valid Azure credentials
Login was successful!
Registering new application in Azure
Application was successfully registered with Azure
Setting identifierUri
Setting signin audience
(node:8840) UnhandledPromiseRejectionWarning: Error: Unable to determine if user is tenant admin:
ERROR: Bad Request({
"error": {
"code": "Request_BadRequest",
"message": "Invalid object identifier 'members'.",
"innerError": {
"date": "2021-02-16T18:55:59",
"request-id": "f6cb935e-edbd-4322-ae09-b11207df8dd1",
"client-request-id": "f6cb935e-edbd-4322-ae09-b11207df8dd1"
}
}
})
at Object.<anonymous> (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:155:19)
at Generator.throw (<anonymous>)
at rejected (C:\repos\xstos\apps\playground\SSO365\node_modules\office-addin-sso\lib\configure.js:4:65)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8840) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:8840) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
C:\repos\xstos\apps\playground\SSO365>
Because configure-sso already succeeded from my home machine, I decided to just try npm run start
on my work machine to see if the missing express module happens. Something weird is happening with that webview prompt. It's not actually prompting due to the below error.
[1] ? Allow localhost loopback for Microsoft Edge WebView? (Y/n) (node:14564) UnhandledPromiseRejectionWarning: false
[0] (Use `node --trace-warnings ...` to show where the warning was created)
[0] (node:14564) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[0] (node:14564) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[0] npm run start:server exited with code 0
Regarding this error:
ERROR: Bad Request({ "error": { "code": "Request_BadRequest", "message": "Invalid object identifier 'members'.", "innerError": { "date": "2021-02-16T18:55:59", "request-id": "f6cb935e-edbd-4322-ae09-b11207df8dd1", "client-request-id": "f6cb935e-edbd-4322-ae09-b11207df8dd1" } } })
Please update to the latest version of office-addin-sso (v.1.0.31) in your project. I am going to update the project template today to use that new version
Right cool forgot about the package.json. Any ideas on how to get past the Allow localhost loopback for Microsoft Edge WebView?
thing? I don't mind hacking it in if need be...
Btw, I just published a new version of the SSO template, so if you create a new SSO project via Yo Office, it will have the "office-addin-sso" package update.
Can you please try the running the following at the root of your project to work around the loopback issue:
No dice. Ran it and saw
C:\repos\xstos\apps\playground\SSO365>npx office-addin-dev-settings appcontainer manifest.xml --loopback
? Allow localhost loopback for manifest.xml? Yes
Loopback is allowed.
But i'm still getting prompted on npm start. Weird.
all good I just commented out the prompt in \node_modules\office-addin-dev-settings\lib\appcontainer.js
function getUserConfirmation(name) {
return __awaiter(this, void 0, void 0, function* () {
const question = {
message: `Allow localhost loopback for ${name}?`,
name: "didUserConfirm",
type: "confirm",
};
//const answers = yield inquirer.prompt([question]);
return "Y";
});
}
I'm glad we're getting closer as I was just tasked to enhance our outlook addin and this empty addin will make that way quicker to prove out. I can obviously set everything up myself like I did in the past, but your scripts/boilerplate save a ton of time. It's actually a shame the azure scripts weren't available when we first started, since one of our guys basically reimplemented the entire thing for deploying dev environments. Duplication of effort sucks, as I imagine every customer building O365 addins is doing the exact same work... I try to DRY but it never works out lol. I miss the excel native days where i could just record macros and customize them. Would be amazing if azure was built that way...
Crap the promise rejection is affecting debugging. I'll try to fix it by disabling strict unhandled rejections...
[0]
[0] > office-addin-taskpane-sso-js@0.0.0 start:server C:\repos\xstos\apps\playground\SSO365
[0] > office-addin-sso start manifest.xml
[0]
[1]
[1] > office-addin-taskpane-sso-js@0.0.0 sideload C:\repos\xstos\apps\playground\SSO365
[1] > office-addin-debugging start manifest.xml
[1]
[1] Debugging is being started...
[1] App type: desktop
[1] Enabled debugging for add-in d10ef321-c728-41de-bf14-c845eda0121f. Debug method: 0
[1] Sideloading the Office Add-in...
[1] Debugging started.
[0] (node:14956) UnhandledPromiseRejectionWarning: false
[0] (Use `node --trace-warnings ...` to show where the warning was created)
[0] (node:14956) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[0] (node:14956) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[1] npm run sideload exited with code 0
[0] npm run start:server exited with code 0
So on the command line I did set NODE_OPTIONS="--unhandled-rejections=none"
that got past the promise rejections. Then it seemed to start wanting to debug. Word opened and the task pane showed but showed a connection error. I'm also seeing the below message. I'm running node v14.15.5
[1] Debugging is being started...
[1] App type: desktop
[1] Enabled debugging for add-in d10ef321-c728-41de-bf14-c845eda0121f. Debug method: 0
[1] Sideloading the Office Add-in...
[1] Debugging started.
[0] npm run start:server exited with code 0
[1]
[1] ┌──────────────────────────────────────────────────────────────────────┐
[1] │ npm update check failed │
[1] │ Try running with sudo or get access │
[1] │ to the local update config store via │
[1] │ sudo chown -R $USER:$(id -gn $USER) C:\Users\xstos\.config │
[1] └──────────────────────────────────────────────────────────────────────┘
[1] npm run sideload exited with code 0
I tried https://stackoverflow.com/a/47861024/1618433 and that seemed to silence the npm error, but now the loading just silently gives up and the node processes just exit even though word shows "add-ins loaded successfully".
[1]
[1] > office-addin-taskpane-sso-js@0.0.0 sideload C:\repos\xstos\apps\playground\SSO365
[1] > office-addin-debugging start manifest.xml
[1]
[0]
[0] > office-addin-taskpane-sso-js@0.0.0 start:server C:\repos\xstos\apps\playground\SSO365
[0] > office-addin-sso start manifest.xml
[0]
[1] Debugging is being started...
[1] App type: desktop
[1] Enabled debugging for add-in d10ef321-c728-41de-bf14-c845eda0121f. Debug method: 0
[1] Sideloading the Office Add-in...
[1] Debugging started.
[1] npm run sideload exited with code 0
[0] npm run start:server exited with code 0
Heyooo it works. I reran configure-sso and somehow that fixed it. The output looks more normal now. I logged in to my O365 test tenant and it works in-browser as well. Phew.
[1]
[1] > office-addin-taskpane-sso-js@0.0.0 sideload C:\repos\xstos\apps\playground\SSO365
[1] > office-addin-debugging start manifest.xml
[1]
[0]
[0] > office-addin-taskpane-sso-js@0.0.0 start:server C:\repos\xstos\apps\playground\SSO365
[0] > office-addin-sso start manifest.xml
[0]
[1] Debugging is being started...
[1] App type: desktop
[1] Enabled debugging for add-in d10ef321-c728-41de-bf14-c845eda0121f. Debug method: 0
[1] Sideloading the Office Add-in...
[1] Debugging started.
[0] You already have trusted access to https://localhost.
[0] Certificate: C:\Users\xstos\.office-addin-dev-certs\localhost.crt
[0] Key: C:\Users\xstos\.office-addin-dev-certs\localhost.key
[0] Server running on 3000
[0] GET /assets/icon-32.png 404 265.380 ms - 1105
[0] GET /assets/icon-64.png 404 269.495 ms - 1105
[0] GET /assets/icon-16.png 404 272.748 ms - 1105
[0] GET /assets/icon-32.png 404 275.862 ms - 1105
[0] GET /assets/icon-32.png 404 5.101 ms - 1105
[0] GET /assets/icon-80.png 404 8.671 ms - 1105 ......
The default template for SSO should be working at this point. If there are still issues please reopen.
Prerequisites
Expected behavior
The generator demo should work
Current behavior
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
1) run generator as above 2) run
npm run configure-sso
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
Failure Logs