0

I have been tasked with extracting SharePoint List schemas for storage and I'm using PnP PowerShell module to do this, we also want to automate this so can't use interactive login, it must be non-interactive.

I have followed PnP's instructions to create an App Reg but left out the instructions for Adding a Platform and redirect URI.

I am trying to test locally to ensure the script works and authenticating with my user email & password as I have Full Control permissions on the website and can access the site via a browser, however I get the below error when running the script

Error occurred: AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance. The returned error contains a claims challenge. For additional info on how to handle claims related to multifactor authentication, Conditional Access, and incremental consent, see https://aka.ms/msal-conditional-access-claims. If you are using the On-Behalf-Of flow, see https://aka.ms/msal-conditional-access-claims-obo for details.

Here is my code:

$encryptedPassword = ConvertTo-SecureString -String $password -AsPlainText -Force
            $creds = New-Object System.Management.Automation.PSCredential -ArgumentList ($username, $encryptedPassword)
            Connect-PnPOnline -Url $targetSite -ClientId $ClientId -Credentials $creds -Verbose

We want to avoid using the other authentication option of a self-signed cert as it requires jumping over many internals hoops to get signed off and using secrets/access tokens are considered legacy methods by PnP.

I can't see what's blocking me from accessing the site programatically?

1
  • 1. Which instructions did you follow? 2. It's being blocked by a conditional access policy. Commented Dec 9, 2024 at 15:41

1 Answer 1

0

The error message you're encountering, indicates that your access to the SharePoint resource is being restricted by Conditional Access policies set within your organization. These policies may require specific conditions to be met, such as device compliance or multi-factor authentication (MFA), which can prevent token issuance when using non-interactive authentication methods.

AADSTS53003: Access has been blocked by Conditional Access policies.

By addressing the Conditional Access policies and potentially using app-only authentication, you should be able to resolve the access issues you're facing.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.