Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from office365.runtime.auth.authentication_context import AuthenticationContext
- from office365.sharepoint.client_context import ClientContext
- username = '@brussels.msf.org'
- password = 'secret'
- url3 = 'https://msfintl.sharepoint.com/sites/OCB/miniOOPS/Documents/Forms/'
- tmp = {}
- res = {}
- ctx_auth = AuthenticationContext(url)
- # auth
- if ctx_auth.acquire_token_for_user(username, password):
- # get context and content
- ctx = ClientContext(url3, ctx_auth)
- web = ctx.web
- ctx.load(web)
- ctx.execute_query()
- # site props
- #tmp['title'] = "Web title: {0}".format(web.properties['Name'])
- # quering for raccolta1
- list_obj = ctx.web.lists.get_by_title('Bolivia')
- folder = list_obj.root_folder
- ctx.load(folder)
- ctx.execute_query()
- # tmp['uri'] = "{0}".format(folder.properties["ServerRelativeUrl"])
- # getting files
- files = folder.files
- ctx.load(files)
- ctx.execute_query()
- tmp['files'] = []
- for cur_file in files:
- obj = {
- 'name': cur_file.properties['Name'],
- 'rel': cur_file.properties['ServerRelativeUrl'],
- 'uuid': cur_file.properties['UniqueId'],
- 'version': cur_file.properties['MajorVersion']
- }
- tmp['files'].append(obj)
- res['msg'] = 'ok'
- res['data'] = tmp
- else:
- res['msg'] = 'err'
- res['data'] = ctx_auth.get_last_error()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement