-
Notifications
You must be signed in to change notification settings - Fork 933
Description
I wasted two full days on this and I'm honestly frustrated that it wasn't documented clearly anywhere.
The Problem
Building a Word add-in that needed to work with personal Microsoft accounts (gmail.com users signing in with their Microsoft account). Kept getting error 13007 with Office.auth.getAccessToken().
I tried everything:
- Switched between single-tenant and multi-tenant configurations
- Changed
signInAudiencefromAzureADMyOrgtoAzureADMultipleOrgstoAzureADandPersonalMicrosoftAccount - Added every possible redirect URI
- Regenerated client secrets multiple times
- Tested with different accounts - work accounts worked fine, personal accounts always failed
- Read through every piece of documentation I could find
Nothing worked. The error was always the same - 13007 or "User is not signed in".
The Solution (turns out it's simple)
After digging through the NAA samples here, I finally figured it out: for sideloaded add-ins with personal Microsoft accounts, you HAVE to use NAA with MSAL.js. The traditional Office.auth.getAccessToken() just doesn't work reliably for personal accounts in sideloading scenarios.
Once I switched to this approach, it worked immediately:
import { createNestablePublicClientApplication } from "@azure/msal-browser";
const msalConfig = {
auth: {
clientId: "your-client-id",
authority: "https://login.microsoftonline.com/common",
supportsNestedAppAuth: true // this flag is critical
}
};
const pca = await createNestablePublicClientApplication(msalConfig);That's it. Two days of debugging for a 10-line fix that would have taken 5 minutes if it was documented.
What I'm asking for
Could you add a note somewhere in the NAA samples (like Samples/auth/Outlook-Add-in-SSO-NAA-Identity/) that explicitly says:
If you're building a sideloaded add-in that needs to support personal Microsoft accounts, use NAA. The standard Office SSO approach will likely fail with error 13007.
Or maybe a troubleshooting section that lists:
- Error 13007 with personal accounts → use NAA instead of Office.auth.getAccessToken()
- Azure config needs
signInAudience: AzureADandPersonalMicrosoftAccount - Redirect URI needs
brk-multihub://localhost:port
The samples in #924, #832, and #860 show HOW to implement NAA, but none of them explain WHEN you need it vs traditional SSO. That's the missing piece.
Would have saved me a lot of headache. Happy to submit a PR if that helps.