Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hsluoyz opened this issue Jan 24, 2018 · 3 comments
Open

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

hsluoyz opened this issue Jan 24, 2018 · 3 comments

Comments

@hsluoyz
Copy link

hsluoyz commented Jan 24, 2018

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 [email protected]. 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, "[email protected]", "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

@esamtian
Copy link

I have same issue when I use this model to visit my SharePoint site, who can support this?

@b0207191
Copy link

well ,my question is
File "/usr/lib/python2.7/urllib2.py", line 527, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 401: Unauthorized

@DuiduiLi
Copy link

Hi,
My suggestion is, the username is the email address, the password is not the computer/email password, it should be the app password. So please create your app follow the guide in https://docs.microsoft.com/zh-cn/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants