Coder Social home page Coder Social logo

vgrem / office365-rest-python-client Goto Github PK

View Code? Open in Web Editor NEW
1.2K 35.0 324.0 18.66 MB

Microsoft 365 & Microsoft Graph Library for Python

License: MIT License

Python 100.00%
office365 sdk-python sharepoint outlook microsoft-graph onedrive microsoft-teams teams onenote planner

office365-rest-python-client's People

Contributors

aisbergg avatar andreas-j-hauser avatar beliaev-maksim avatar caleb-depotanalytics avatar deadscop avatar dependabot[bot] avatar domdinicola avatar gd-kgadek avatar hsluoyz avatar jojo0severo avatar juguerre avatar kellerza avatar kfsz avatar liuliqiu avatar lsgd avatar nsmcan avatar padamscrestonecapital avatar philipp-c avatar rebeccajhampton avatar rikeshtailor avatar takatsugu-kato avatar thaiphv avatar theodoriss avatar timurgen avatar toilal avatar tomkcook avatar vgrem avatar wreiner avatar yusuf-asm avatar zahlii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

office365-rest-python-client's Issues

Fix tests 2/2: failing test_3_download_file

$ nosetests tests.test_file:TestFile.test_3_download_file
F
======================================================================
FAIL: Test file upload operation
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kgadek/gd/git/m1e/Office365-REST-Python-Client/tests/test_file.py", line 41, in test_3_download_file
    self.assertEqual(response.content, '"' + self.report_content + '"')
AssertionError: '"123"' != '"Report data"'
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): login.microsoftonline.com
requests.packages.urllib3.connectionpool: DEBUG: https://login.microsoftonline.com:443 "POST /extSTS.srf HTTP/1.1" 200 3824
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "POST /_forms/default.aspx?wa=wsignin1.0 HTTP/1.1" 302 118
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET / HTTP/1.1" 302 179
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /SitePages/DevHome.aspx HTTP/1.1" 200 47348
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /sites/contoso/_api/Web/lists/GetByTitle('Documents') HTTP/1.1" 200 None
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /sites/contoso/_api/web/getfilebyserverrelativeurl('/sites/contoso/documents/report.csv')/%5C$value HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 1 test in 3.633s

FAILED (failures=1)

Lack Unicode support: UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Hi,

My Office 365 is in Chinese language. When I run the example: examples\user_group_operations.py, it gave me the error:

C:\Python27\python.exe J:/github_repos/Office365-REST-Python-Client/examples/user_group_operations.py
Traceback (most recent call last):
  File "J:/github_repos/Office365-REST-Python-Client/examples/user_group_operations.py", line 43, in <module>
    read_groups(ctx)
  File "J:/github_repos/Office365-REST-Python-Client/examples/user_group_operations.py", line 13, in read_groups
    print("Group title: {0}".format(group.properties["Title"]))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128)

Process finished with exit code 1

When I debug the code, I found that the returned groups contain Chinese characters, which causes the error.

def read_groups(ctx):
    """Read site groups example"""
    groups = ctx.web.site_groups
    ctx.load(groups)
    ctx.execute_query()

    for group in groups:
        print("Group title: {0}".format(group.properties["Title"]))  # <---- here contains non-English chars

Can you add the Unicode support for this library? Thanks.

There were a few import issues

Encountered a few issues with imports when running your example code.

list_collection.py
changed from list import List to from .list import List

site.py
changed from web import Web to from .web import Web

resource_path is not a str? or is a str type?

I'm trying to get the view list of views by using the example, but always met such issue.
could you help?

========== code
url="https://xxx.sharepoint.com/sites/xxxx"
ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):

ctx = ClientContext(url, ctx_auth)

web = ctx.web
#print("web resource_path{}".format(web.resource_path))

ctx.load(web)
ctx.execute_query()
print ("Web title: {0}".format(web.properties['Title']))

issue here when calling -> print_list_views(ctx)

======================

File "C:\python36\lib\site-packages\office365\sharepoint\view_collection.py", line 10, in get_by_title
resourcePath = self.resource_path + "/getbytitle('{0}')".format(view_title)
TypeError: unsupported operand type(s) for +: 'ResourcePathEntry' and 'str'

Fix tests 1/2: failing test_1_upload_file

The problem is just with the paths:

$ pwd
SOMEPATH/Office365-REST-Python-Client
$ nosetests tests.test_file:TestFile.test_1_upload_file
E
======================================================================
ERROR: test_1_upload_file (tests.test_file.TestFile)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "SOMEPATH/Office365-REST-Python-Client/tests/test_file.py", line 25, in test_1_upload_file
    with open(self.source_path, 'r') as content_file:
IOError: [Errno 2] No such file or directory: '../examples/data/report.csv'
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): login.microsoftonline.com
requests.packages.urllib3.connectionpool: DEBUG: https://login.microsoftonline.com:443 "POST /extSTS.srf HTTP/1.1" 200 3824
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "POST /_forms/default.aspx?wa=wsignin1.0 HTTP/1.1" 302 118
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET / HTTP/1.1" 302 179
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /SitePages/DevHome.aspx HTTP/1.1" 200 47382
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /sites/contoso/_api/Web/lists/GetByTitle('Documents') HTTP/1.1" 200 None
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 1 test in 6.170s

FAILED (errors=1)
$ cd tests
$ nosetests tests.test_file:TestFile.test_1_upload_file
.
----------------------------------------------------------------------
Ran 1 test in 6.891s

OK

ImportError: No module named client.AuthenticationContext

The sample in readme returns error.

$ ipython ./office365.py                                       
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/usr/lib/python2.7/dist-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
    202             else:
    203                 filename = fname
--> 204             __builtin__.execfile(filename, *where)

/tmp/sharepoint_script/office365.py in <module>()
----> 1 from client.AuthenticationContext import AuthenticationContext
      2 from client.ClientRequest import ClientRequest
      3 
      4 url = "https://OURCORPORATE.sharepoint.com/"
      5 username = "[email protected]"

ImportError: No module named client.AuthenticationContext

More info

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.5 LTS
Release:        14.04
Codename:       trusty

$ pip list|grep -i Office365
Office365-REST-Python-Client (2.0.0)

$ ll office365.py 
-rwxr-xr-x 1 catcat 2cats 582 Nov  2 16:41 office365.py*

$ more office365.py 
from client.AuthenticationContext import AuthenticationContext
from client.ClientRequest import ClientRequest

url = "https://OURCORPORATE.sharepoint.com/"
username = "[email protected]"
password = "password_that_works"

ctxAuth = AuthenticationContext(url)
if ctxAuth.acquireTokenForUser(username, password):
  request = ClientRequest(url,ctxAuth)
  requestUrl = "/_api/web/"   #Web resource endpoint
  data = request.executeQuery(requestUrl=requestUrl)

  webTitle = data['d']['Title']
  print "Web title: {0}".format(webTitle)

else:
  print ctxAuth.getLastErrorMessage()

Authentication Problems

Hi,

I use sharepoint in Cloud and from yesterday I have an authentication error: "An error occurred while retrieving token: AADSTS70002: Error validating credentials. AADSTS50126: Invalid username or password. An error occurred while retrieving auth cookies"

Do you have some similar issues? It's a problem of Azure AD??

many thanks for support

Andrea

Package and deploy new code

Since v1.1.0, there was only one but big change to codebase, namely #30.

$ git log --first-parent tags/v1.1.0..origin/master
commit a7516ea6112bcca2ed832501842c1a7d73149206 (HEAD -> master, origin/master, origin/HEAD)
Merge: d0641e7 cc96e6b
Author: Vadim Gremyachev <[email protected]>
Date:   Thu Jun 29 14:26:27 2017 +0300

    Merge pull request #30 from Maplecroft/master

    Move `office365` module to the top level

cc96e6b (merged above) changed the API of the package, so major version bump will be needed.

oAuth not implemented yet

it looks like the repo has oAuth file in runtime/auth, but not implemented. (or at least it seems that way) Would there be any interest in the community for this feature?

Listing files in a folder doesn't work as expected

I am working with a slightly modified version of file_operations.py example, as the Sharepoint instance I'm working with doesn't have any lists. Thus, I am trying to obtain files like so:

    folder = ctx.web.get_folder_by_server_relative_url('/')
    ctx.load(folder)
    ctx.execute_query()
    files = folder.files
    ctx.load(files)
    ctx.execute_query()

This yields ValueError: ('Response error:', {u'lang': u'en-US', u'value': u'Cannot find resource for the request Files.'})

Looking at the code, it seems that when the folders are fetched, the class constructor does not include the current resource path, and therefore when invoking folder.files, no valid URL is constructed. Indeed, the request becomes "GET //_api/Files" as opposed to the expected "GET http://myhost/_api/Web/GetFolderByServerRelativeUrl('%2f')/Files". Looks like a bug to me.

(Grepping for "__deferred" it doesn't seem that the resource URIs in __deferred objects are being parsed or used anywhere, so I imagine the URIs must be constructed from ResoucePath objects.)

Using app password

I love this client and have been using it very successfully for a while now. However, my organization has just enabled multi-factor authentication for Office 365 which has broken my application - ๐Ÿ‘Ž.

Do you have any examples you can share of using app passwords or other techniques for accessing O365 when multi-factor authentication is enabled?

Thanks!

NameError: name 'basestring' is not defined

I am getting an error when running your example code for file listing from Sharepoint.

NameError: name 'basestring' is not defined

@staticmethod
    def encode_method_value(value):
        if isinstance(value, basestring):
            value = "'{0}'".format(value)
        elif isinstance(value, bool):
            value = str(value).lower()
        return value

Post Headers

Hi,
I had to change the following two POST calls in saml_token_provider.py to resolve an authentication problem, can you integrate these changes?

  1. def acquire_service_token
  • response = requests.post(sts_url, data=request_body, headers={'Content-Type': 'application/x-www-form-urlencoded'})
  1. def acquire_authentication_cookie
  • session.post(url, data=self.token, headers={'Content-Type': 'application/x-www-form-urlencoded'})

Thanks
Andrea

Url lib package has to be changed for Python 3

instead of
from urlparse import urlparse

we need to use
from urllib.parse import urlparse

and finally under saml_token_provider.py
change urlparse.urlparse(self.url)
to
urlparse(self.url)

Logging

I want to discuss adding logging to the system.

Use-case

The script I have failed once. Stacktrace points at saml_token_provider.py suggesting that the cookie from sharepoint was incorrect. I'd love to see more logs about this.

Proposal

  • use logging module throughout the library to trace variables and function calls,
  • function calls get logging.INFO level, while internal variables logging.debug unless they contain any secrets,
  • register new logging level logging.DEBUG_SECRETS=5 to log variables containing secrets. Very useful e.g. to inspect the cookies / SAML protocol.

get_items() of a view

Is it possible to iterate through the items in a view like you can with a list ?

Thanks

How to add modules

It would be great with a simple installation guide! I appreciate your work!

Deleting list items does not work

The examples seem outdated when it comes to using ClientRequest objects. The constructor does not seem to take both a url and AuthenticationContext anymore and execute_query_direct now takes one RequestOptions object instead of several parameters.

I have tried to recreate the example using the current API, but have not succeeded. The below code at least, results in a requests library error: 'AuthenticationContext' object is not callable.

ctx_auth = AuthenticationContext(url)
        if ctx_auth.acquire_token_for_user(username, password):
            request = ClientRequest(ctx_auth)
            url = "{0}/_api/web/lists(guid'{1}')/items({2})".format(
                url,
                list_guid,
                item_id)
            options = RequestOptions(url)
            options.set_header('IF-MATCH', '*')
            options.set_header('X-HTTP-Method', 'DELETE')
            options.method = HttpMethod.Delete
            options.auth = ctx_auth
            data = request.execute_query_direct(options)
        else:
            print ctx_auth.get_last_error()

Can you please help me understand how to delete list items using the current API?

Getting more than 100 items from a list

I've been using examples/listitem_operations.py read_list_items() as a basis for a project I'm working on, and have hit a problem in that only the first 100 items in my list are returned.

This suggests that the underlying issue is that the underlying Sharepoint REST API is limited to returning 100 items at a time by default as a protection measure. There are some nasty hacks with $top= to increase the limit, but it appears the right way of retrieving an arbitrary number of items is to look for the existence of a link of the following form:

<feed>
   ...
   <link rel="next" href=".../items?%24skiptoken=Paged%3dTRUE%26p_ID%3d100" />
</feed> 

on each set of results (the ... above is a contraction of the REST resource URI). This indicates that there are additional results, and provides a link to the next page.

Is accessing paged results possible with this client? Apologies if I'm missing something, but I can't find anything immediately obvious.

How can i upload a file to sharepoint ?

I am trying to upload a file to sharepoint, am I on the right path ?

def upload_file(ctx, listTitle, path):
    list_obj = ctx.web.lists.get_by_title(listTitle)
    folder = list_obj.root_folder
    ctx.load(folder)
    ctx.execute_query()

    files = folder.files
    with open(path, 'rb') as f:
        content = f.read()
        file_creation_information = FileCreationInformation()
        file_creation_information.overwrite = True
        file_creation_information.url = path
        file_creation_information.content = content
        file_new = files.add(file_creation_information)

"TypeError: cannot concatenate 'str' and 'NoneType' objects" on request to get a file.

I'm trying to download a file which is accessible (via a browser) on this URL:
https://test.sharepoint.com/sites/team/team documents/subfolder/document.docx

I'm using a ClientRequest object with the following code:

url = "https://test.sharepoint.com/sites/team"
username="[email protected]"
password="pass"
ctxAuth = AuthenticationContext(url)
if ctxAuth.acquire_token_for_user(username, password):
    print 'authentication successful, proceeding...'
    request = ClientRequest(ctxAuth)
    requestUrl="{0}/_api/web/getfilebyserverrelativeurl('team documents/subfolder/document.docx')"
    options=RequestOptions(requestUrl.format(url))
    data = request.execute_query_direct(options)

On running this, I'm getting the following trace:

$ python test.py
No handlers could be found for logger "client.office365.runtime.auth.saml_token_provider.SamlTokenProvider.process_service_token_response"
authentication successful, proceeding...
Traceback (most recent call last):
  File "test.py", line 14, in <module>
    data = request.execute_query_direct(options)
  File "/usr/lib/python2.7/site-packages/client/office365/runtime/client_request.py", line 77, in execute_query_direct
    self.context.authenticate_request(request_options)
  File "/usr/lib/python2.7/site-packages/client/office365/runtime/auth/authentication_context.py", line 20, in authenticate_request
    request_options.set_header('Cookie', self.provider.get_authentication_cookie())
  File "/usr/lib/python2.7/site-packages/client/office365/runtime/auth/saml_token_provider.py", line 65, in get_authentication_cookie
    return 'FedAuth=' + self.FedAuth + '; rtFa=' + self.rtFa
TypeError: cannot concatenate 'str' and 'NoneType' objects

Is there something wrong on how I use the module?

Package doesn't contain SAML.xml file

File "/Users/kgadek/someproject/py2-venv/lib/python2.7/site-packages/client/office365/runtime/auth/saml_token_provider.py", line 112, in prepare_security_token_request
    f = open(os.path.join(os.path.dirname(__file__), 'SAML.xml'))
IOError: [Errno 2] No such file or directory: '/Users/kgadek/someproject/py2-venv/lib/python2.7/site-packages/client/office365/runtime/auth/SAML.xml'

Delete all list items

Hi there!

I want to delete all items from a Sharepoint list.

list_object = ctx.web.lists.get_by_title(listname)
items = list_object.get_items()
ctx.load(items)
ctx.execute_query()
for item in items:
    item.delete_object()

This does not seem to work. Could anyone explain how to delete all items from a list?

Thanks in advance!

Fix examples

The examples use older API. After name convention changed, those examples do not work anymore.

Task

Fix them

SSL Connection Error

i am facing the below error while trying through rest api

Error: HTTPSConnectionPool(host='xxxx', port=443)
retries exceeded with url: /_forms/default.aspx?wa=wsignin1.0 (Caused by S
r(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:777)'),))

Trouble uploading document with encoding

Attempting in various ways to upload a file to Sharepoint without dismissing the encoding. Just a text or log file, but after uploading, I'm seeing new line characters (\n) and carriage returns (\r) all over the place.

I've tried via ClientRequest and ClientContext, and have been able to upload files both to a Document Library and to a List, but I'm sort of stumped at this point. Is there a header I can set to let SharePoint know of the encoding?

Pip install is not referencing the latest version

Thanks for the great library.
A quick note for others, the pip install does not reference the latest changes.

For instance 'acquire_token_for_app' in the AuthenticationContext does not exist.

Cheers!

Python3

It is possible to add compatibility with Python3 ?

Consider renaming (or dropping) the top-level package

The name client is pretty generic and seems unnecessary (since there's only one sub-module) - could you consider deleting it and having the top-level module be office365 instead? It would mean updating all the docs, tests, etc but that should be relatively easy with a simple find and replace...

Release version 2.1.1, to PyPI?

Today I tried this library. I could get the v2.0.0 to work with Microsofts current Office365. I also tried checking out the GitHub version and installed it manually, this worked. Is it possible to release v2.1.1 to PyPI too so it can be installed with PIP?

An error occured while retrieving token: The entered and stored passwords do not match.

Hi @vgrem,

First of all, thanks a lot for this library!
I was trying this out to connect to SharePoint Online with Python but I directly got an error.
The code:

from client.auth.AuthenticationContext import AuthenticationContext
from client.ClientContext import ClientContext
from settings import settings

url = "https://mycompany.sharepoint.com/"
username = "[email protected]"
password = "password"


ctxAuth = AuthenticationContext(url)
if ctxAuth.acquireTokenForUser(username, password):
  request = ClientRequest(url,ctxAuth)
  requestUrl = "/_api/web/"   #Web resource endpoint
  data = request.executeQuery(requestUrl=requestUrl)

  webTitle = data['d']['Title']
  print "Web title: {0}".format(webTitle)

else:
  print ctxAuth.getLastErrorMessage()

I've added this to a Python file named connector.py. When executing this code I will get the error:

An error occured while retrieving token: The entered and stored passwords do not match.

So, why am I getting this and how should I fix this? On a sidenote: what is the correct way to install this library in Linux? I've now manually downloaded it and added it in the same folder where my connector.py file is but I know thats not really the good way.

Thanks,
Yenthe

How to expose Page to html?

Hi,

Thanks for this great library.
I have a few questions

  • can we export Sharepoint page to html files?
  • Can we export List item to excel?
  • Can we download document?

My ultimate goal is exporting sharepoint and its associated contents to Google Sites but have no any clue for now.

Thanks,
Van

Session and proxy support

Could be great to support proxy connections for those behind a web proxy. Please take into account NTLM proxies too.

... and support session instead of one request per operation. I.e make lots of request reusing same tcp/ssl connection.

Could be great to publish some big example code using class tests... Today the doc support is really poor and need to investigate inside the code to figure how to use it.

Thanks in advance for your great effort.

How to update a single list item?

I am using the update method of SharePoint listitem.py
item_object.update()
but how can I put the data I want to update? for instance:
item_properties = {'__metadata': {'type': 'SP.Data.'+listTitle+'ListItem'},
'Title': 'new item',
'Value':99,
}
and then update the item...

office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_authentication_cookie

I essentially cut and pasted examples into ipython and received the following error:

No handlers could be found for logger "office365.runtime.auth.saml_token_provider.SamlTokenProvider.acquire_authentication_cookie"
Traceback (most recent call last):
  File "outlook365-calendar-read.py", line 19, in <module>
    data = request.execute_request_direct(options)
AttributeError: 'ClientRequest' object has no attribute 'execute_request_direct'

I could look into writing such a handler, but I'm at such an early stage with office365 api dev that I'm not even sure if that's a wild goose chase.

Unable to import

I am unable to import the module for some reason, i am using Python 3.6
Any ideas ?

Traceback (most recent call last):
File "C:/Users/me/Projects/o365/snippets/sharepoint.py", line 14, in
from office365.runtime.auth.authentication_context import AuthenticationContext
ModuleNotFoundError: No module named 'office365'

Publish as PyPI package

Hi.

Did you consider publishing the code here as PyPI package? It works for my use case, which is exceptional! Being able to pip install office365-rest-client would be terrific.

I can help with this by providing PR with proper metadata. I also volunteer to maintain the package if you don't mind (the examples are bit outdated, but easy to fix).

Unit tests fail

Even for older commits which originally succeeded, the nosetests fail. Appears that the server (the global state) changed:

$ git rev-parse --short @
7dc8de9

$ nosetests
...........E.........
======================================================================
ERROR: test_create_list_item (tests.test_listItem.TestListItem)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/kgadek/PROJECT/Office365-REST-Python-Client/tests/test_listItem.py", line 14, in test_create_list_item
    self.context.execute_query()
  File "/Users/kgadek/PROJECT/Office365-REST-Python-Client/client/office365/runtime/client_runtime_context.py", line 33, in execute_query
    self.pending_request.execute_query()
  File "/Users/kgadek/PROJECT/Office365-REST-Python-Client/client/office365/runtime/client_request.py", line 23, in execute_query
    self.process_payload_json(qry, payload)
  File "/Users/kgadek/PROJECT/Office365-REST-Python-Client/client/office365/runtime/client_request.py", line 33, in process_payload_json
    raise ValueError("Response error:", payload['error']['message'])
ValueError: ('Response error:', {u'lang': u'en-US', u'value': u"List 'Tasks' does not exist at site with URL 'https://mediadev19.sharepoint.com/sites/contoso'."})
-------------------- >> begin captured logging << --------------------
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): login.microsoftonline.com
requests.packages.urllib3.connectionpool: DEBUG: https://login.microsoftonline.com:443 "POST /extSTS.srf HTTP/1.1" 200 3824
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "POST /_forms/default.aspx?wa=wsignin1.0 HTTP/1.1" 302 118
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET / HTTP/1.1" 302 179
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "GET /SitePages/DevHome.aspx HTTP/1.1" 200 46962
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "POST /sites/contoso/_api/contextinfo HTTP/1.1" 200 None
requests.packages.urllib3.connectionpool: DEBUG: Starting new HTTPS connection (1): mediadev19.sharepoint.com
requests.packages.urllib3.connectionpool: DEBUG: https://mediadev19.sharepoint.com:443 "POST /sites/contoso/_api/Web/lists/GetByTitle('Tasks')/items HTTP/1.1" 404 None
--------------------- >> end captured logging << ---------------------

----------------------------------------------------------------------
Ran 21 tests in 101.906s

FAILED (errors=1)

Access denied when accessing folders

Hello!

I am an organisation collaborator and when I try to access to folders I get always Access denied. What am I missing here? Shouldn't I be able to access to my folders?

Sample code here:

def read_folder_and_files():

    print(ctx.web.service_root_url)
    """Read a folder example"""
    folders = ctx.web.folders
    ctx.load(folders)
    ctx.execute_query()
    for folder in folders:
        print("Folder name: {0}".format(folder.properties["Name"]))



if __name__ == '__main__':
    print(settings['url'])
    ctx_auth = AuthenticationContext(url=settings['url'])
    if ctx_auth.acquire_token_for_user(username=settings['user_credentials']['username'],
                                       password=settings['user_credentials']['password']):
        ctx = ClientContext(settings['url'], ctx_auth)

        read_folder_and_files()

    else:
        print(ctx_auth.get_last_error())

ValueError: ('Response error:', {u'lang': u'en-US', u'value': u'Access denied. You do not have permission to perform this action or access this resource.'})

Thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.