Python Forum
sharepoint: Access has been blocked by Conditional Access policies
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sharepoint: Access has been blocked by Conditional Access policies
#1
I'm trying to access an excel sheet to extract data, but it is on sharepoint which makes things a bit more complicated.

I'm using this code (snippet):

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext
 site_url = 'site_url'
        username = 'username'
        password = 'password'

        ctx_auth = AuthenticationContext(site_url)
        if ctx_auth.acquire_token_for_user(username, password):
            ctx = ClientContext(site_url, ctx_auth)
            web = ctx.web
            ctx.load(web)
            ctx.execute_query()
            print('Authenticated into SharePoint as:', web.properties['Title'])
but I'm seeing:

Error:
An error occurred while retrieving token from XML response: AADSTS53003: Access has been blocked by Conditional Access policies. The access policy does not allow token issuance.
Is there a way around this? I don't have many permissions on my organisations sharepoint, and the IT technician responded saying:

Quote:There must be another authentication method made available by Microsoft (“Modern authentication”). The method you use falls under “Legacy authentication” that is set to be deprecated by the end of the year.

He also recommended I use make, but I prefer coding things myself, and I'm trying to use this code for a college project. I've not coded a lot with python at all, so I want to continue to use it to learn.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Script problem - Illegal access to removed OSM object MarcPolo72 0 878 Jun-23-2024, 04:26 PM
Last Post: MarcPolo72
  Circumvent the "access denied" page? Pedroski55 7 2,052 Jun-15-2024, 06:25 AM
Last Post: Pedroski55
  How to get all items in SharePoint recycle bin by using sharepy library in Python? QuangHuynh 2 1,487 Apr-10-2024, 03:09 PM
Last Post: SandraYokum
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 1,216 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  How to access values returned from inquirer cspower 6 2,478 Dec-26-2023, 09:34 PM
Last Post: cspower
  Updating sharepoint excel file odd results cubangt 1 1,981 Nov-03-2023, 05:13 PM
Last Post: noisefloor
  Pytest Installed, but VS Code Won’t Access Pytest AstralWeeks 9 15,008 Sep-13-2023, 03:00 PM
Last Post: AstralWeeks
  How can I access objects or widgets from one class in another class? Konstantin23 3 2,455 Aug-05-2023, 08:13 PM
Last Post: Konstantin23
  Access list of dictionaries britesc 4 2,534 Jul-26-2023, 05:00 AM
Last Post: Pedroski55
  Subtitle Access jrockow 3 1,774 Jun-26-2023, 03:12 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020