I've been using an OfficeDevPnp.Core.AuthenticationManager
for a long time, in order to support MFA for PowerShell scripts targeting SharePoint Online with CSOM.
For my current task, DEV is on tenant-1, whereas TEST and PROD are on tenant-2.
I use [email protected] for DEV, and [email protected] for TEST and PROD.
For some reason today, when switching from DEV to TEST, when I'm expecting to be prompted to authenticate as [email protected], the auth prompt popped up briefly but for some reason performed authentication with [email protected].
Hence, the script failed with a 403 for a CSOM ExecuteQuery() call. Now I can't seem to get it to a state where I can interactively provide my [email protected] credentials for tenant-2. I've even restarted the machine.
My code is nothing special:
$siteURL = "https://tenant-2.sharepoint.com/sites/TEST"
$authmgr = new-object OfficeDevPnp.Core.AuthenticationManager
$ctx = $authmgr.GetWebLoginClientContext($siteURL)
Is there a way to flush the credentials cache? I don't recall having this problem previously; ordinarily I just specify the site URL and if the Authentication Manager can't find a suitable native tenant user, it prompted me for one.