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 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.
snippet of code for authentication:
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'])
I’ve found a method to fix this issue by creating a new app and using client credentials and not user credentials, but I do not have many permissions, so all I can do is edit certain files such as the production schedule, purchasing requisitions sheet etc.
This should allow me to sign in and view data from the excel sheet which I am trying to access (I’ve only put the authentication code in as that is the only part that is currently relevant), but I do not have permission. My organisation want me to automate things, but won’t give me admin or any control within SharePoint, so I have no idea what to do. I can’t find appregnew.aspx, cannot create apps etc. Most of my permissions are blocked, so any solution I have found to this problem so far have not worked for me.
CAD79 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.