Question

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 me@tenant-1.com for DEV, and otherme@tenant-2.com for TEST and PROD.

For some reason today, when switching from DEV to TEST, when I'm expecting to be prompted to authenticate as otherme@tenant-2.com, the auth prompt popped up briefly but for some reason performed authentication with me@tenant-1.com.

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 otherme@tenant-2.com 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.

Was it helpful?

Solution

Silly me. The resolution is to delete the relevant cookies from the machine, after which the next execution of the script surfaces the prompt again, in this case allowing me to provide the correct credentials for tenant-2.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top