OfficeDev / Office-Add-in-samples

Code samples for Office Add-in development on the Microsoft 365 platform.
MIT License
709 stars 783 forks source link

Outlook-Add-in-SSO-NAA worked only once. I can't get any token anymore #818

Open canturan opened 2 months ago

canturan commented 2 months ago

Note: This repo is only for questions related to its samples. If you have questions about how to use office.js or the Office developer platform, please post your question on https://stackoverflow.com. Tag your question with office-js or outlook-web-addins

Question

I was testing the NAA configuration with the Outlook-Add-in-SSO-NAA sample. After I followed the steps and started the application, the get user button opened a popup, where I consented the permissions for my tenant and the graph call worked.

But when I start the application again, I can get any token anymore:

this.pca.getAccount on the initilize return undefined for the account

On the method "ssoGetUserIdentity", because the this.account is undefined, the this.pca.ssoSilent is called, which returns the following error:

'ServerError\n at NestedAppAuthAdapter.fromBridgeError (https://localhost:3000/taskpane.js:13261:28)\n at NestedAppAuthController.acquireTokenSilentInternal (https://localhost:3000/taskpane.js:6960:53)\n at async AccountManager.ssoGetUserIdentity (https://localhost:3000/taskpane.js:315:12)\n at async HTMLButtonElement.getUserData (https://localhost:3000/taskpane.js:451:23)'

Then on the catch block, the application tries to login the user with this.pca.acquireTokenPopup which return the following error on the popup window.

image

I did not change anything on the sample. It worked on the first run then not anymore. Could please help me?

Thanks!

AlexJerabek commented 2 months ago

Thanks for reporting this @canturan.

@davidchesnut, could you please take a look?

davidchesnut commented 2 months ago

Hi @canturan,

Sorry you ran into this issue. This is a product bug we're working to fix soon. We'll post an update here once the fix is available.

canturan commented 2 months ago

@davidchesnut : Thank you for the update.

In the meantime, I found a workaround but mybe the information could help you to figure out the issue.

I set up a complete new dev VM, joined it to Entra ID of my dev tenant then set up Outlook etc. In this combination, everything works as expected.

But if I try to test it in a maschine which logged in with Microsoft account and I am logged in to Office + Outlook with my M365 Work account then I can reproduce the issue which I explained in my first message.

davidchesnut commented 8 hours ago

Hi @canturan,

Can you please confirm if you are still seeing this issue? Should be fixed now. Thanks!