1

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.

1
  • Duh... delete cookies on the machine. It must be time for a break.
    – sasfrog
    Jul 28, 2020 at 7:15

1 Answer 1

0

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.

1
  • ...I've come back here a few times to remind myself. As of today, I still need to do this using Internet Options via IE or control panel, not Edge/Chrome cache clearing.
    – sasfrog
    Nov 25, 2021 at 5:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.