1

I'm trying to read data from an HTML table that on a site with a URL like https://mysharepoint.sharepoint.com/sites/mySite/sitepages/tables

And I only have access to the "mySite" site. I've tried using shareplum like their documentation:

from shareplum import Site
from shareplum import Office365

authcookie = Office365('https://abc.sharepoint.com', username='username@abc.com', password='password').GetCookies()
site = Site('https://abc.sharepoint.com/sites/MySharePointSite/', authcookie=authcookie)

But I then get the following error: "requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://abc.sharepoint.com/sites/MySharePointSite/_vti_bin/lists.asmx"

I'm guessing that this is precisely because I don't have access to the root site, but I've also tried doing:

authcookie = Office365('https://abc.sharepoint.com/sites/MySharePointSite/', username='username@abc.com', password='password').GetCookies()
site = Site('https://abc.sharepoint.com/sites/MySharePointSite/', authcookie=authcookie)

But that generated the same error.

Does anyone know a way to specify to shareplum that I want to use my credentials for that specific site, or a way without using shareplum entirely?

Lophyre
  • 11
  • 1

1 Answers1

0

Issue #105 on the SharePlum GitHub repo suggests a workaround: in shareplum/request_helper.py, comment out the following line in the post function (ln.17 for v0.5.1): response.raise_for_status()

This results in accepting the 403 return status, which you get for not having access to the root site. For me this solved the problem as the authentication actually was successful, and I could use the returned authcookie to work with the SharePoint sub-site.

JGS
  • 1
  • 1