Skip to content

Alwasy get urllib2.HTTPError: HTTP Error 403: Forbidden #35

Description

@hsluoyz

Hi. This is how I use the code. And I always get the 403 error. In the web browser, I always use the email account to login. I don't know the username here is the Email address I used to login the www.office.com website? The username I used is xxx@pku.edu.cn. Is this right? Or I should use some translated names like pku_edu_cn\\xxx?

from sharepoint import SharePointSite, basic_auth_opener

server_url = "https://pkueducn-my.sharepoint.com/"
site_url = server_url + "personal/xxx_pku_edu_cn"

opener = basic_auth_opener(server_url, "xxx@pku.edu.cn", "my_password")

site = SharePointSite(site_url, opener)

for sp_list in site.lists:
    print sp_list.id, sp_list.meta['Title']

My error:

C:\Python27\python.exe J:/github_repos/xxx/sp.py
Traceback (most recent call last):
  File "J:/github_repos/xxx/sp.py", line 17, in <module>
    for sp_list in site.lists:
  File "C:\Python27\lib\site-packages\sharepoint\lists\__init__.py", line 80, in __iter__
    return iter(self.all_lists)
  File "C:\Python27\lib\site-packages\sharepoint\lists\__init__.py", line 36, in all_lists
    result = self.opener.post_soap(LIST_WEBSERVICE, xml)
  File "C:\Python27\lib\site-packages\sharepoint\site.py", line 32, in post_soap
    response = self.opener.open(request, timeout=self.timeout)
  File "C:\Python27\lib\urllib2.py", line 435, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 548, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 473, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 407, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 403: Forbidden

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions