Skip to main content

Automation of some processes on office365

Project description

Automation of some processes on office365



1. Create session user


get the value of entry_point

Image

from Onedrive import OneDrive

username = "XXXXXXXXXXXXXXXXXXXXXX"
password = "XXXXXXXXXXXXXXXXXXXXXX"
entry_point = "https://<tenant_name>.sharepoint.com/personal/<username>"

session = OneDrive(username = username, password = password, url_user = entry_point)



2. Get folders

folders = session.get_folders_endpoint()

for folder in folders:  

    print(folder.name)

Folder Properties

To see all the properties of a file, use the properties attribute. For example

    print(folder.properties) 

output

{
    'Exists': True,
    'IsWOPIEnabled': False,
    'ItemCount': 0,
    'Name': <folder_name>,
    'ProgID': None,
    'ServerRelativeUrl': '/personal/<tenant>/Documents/<folder_name>',
    'TimeCreated': '2022-10-10T12:58:09Z',
    'TimeLastModified': '2022-10-10T12:58:09Z',
    'UniqueId': '16636378-fd57-4456-9e0f-1331d62f1385',
    'WelcomePage': ''
}



3. Get files

files = session.get_files_from_folder()

print(*files, seq="\n")

File Properties

{
    'CheckInComment': '',
    'CheckOutType': 2,
    'ContentTag': '{263E029D-372D-476B-9609-1F84D2C9B578},1,1',
    'CustomizedPageStatus': 0,
    'ETag': '"{263E029D-372D-476B-9609-1F84D2C9B578},1"',
    'Exists': True,
    'IrmEnabled': False,
    'Length': '36653',
    'Level': 1,
    'LinkingUri': '<tenant>/Documents/<filename>.csv?d=w263e029d372d476b96091f84d2c9b578',
    'LinkingUrl': '<tenant>/Documents/<filename>.csv?d=w263e029d372d476b96091f84d2c9b578',
    'MajorVersion': 1,
    'MinorVersion': 0,
    'Name': 'KOLDA.csv',
    'ServerRelativeUrl': '/personal/<tenant>/Documents/<filename>.csv',
    'TimeCreated': '2022-10-07T12:32:38Z',
    'TimeLastModified': '2022-10-07T12:32:38Z',
    'Title': None,
    'UIVersion': 512,
    'UIVersionLabel': '1.0',
    'UniqueId': '263e029d-372d-476b-9609-1f84d2c9b578'
}



4. Create folder

session.create_folder_on_onedrive(folder_name)



5. Download files from folder

session.download_files_from_folder(folder_name_on_onedrive)



6. Upload files local to onedrive folder

session.upload_files_to_onedrive(path_folder_name_local, folder_name_onedrive)

Upload single file on OneDrive

session.upload_file_to_onedrive(path_file_name_local, folder_name_onedrive)



7. Share folder with Anonymous

session.share_folder(<folder_name>)

output

Link like this => https://<tenant>.sharepoint.com/:f:/g/personal/<username>/EnhjYxZX_VZEng8TMdYvE4UB78vdTFHSEs3vc5FgqQ1A8Q

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

onedrive-sharepoint-0.0.24.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

onedrive_sharepoint-0.0.24-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file onedrive-sharepoint-0.0.24.tar.gz.

File metadata

  • Download URL: onedrive-sharepoint-0.0.24.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for onedrive-sharepoint-0.0.24.tar.gz
Algorithm Hash digest
SHA256 9b9b0efd91c38b3aaaeae2c77690e275619294bc4e66094a363499622f62fc1c
MD5 a8d7c578f1bfecc79a5908fc4cdbca22
BLAKE2b-256 bb71c011bfa8d6dc1b331c9be8d3a8f9b58daa7ec2fd0b5730fed142d3db48ed

See more details on using hashes here.

File details

Details for the file onedrive_sharepoint-0.0.24-py3-none-any.whl.

File metadata

File hashes

Hashes for onedrive_sharepoint-0.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 32331f6933feef22c780e49e3c00a0c99cad86fe272cd406bfafaa0e7b064f8b
MD5 ae24235a104488cfb6da52b627f2b4eb
BLAKE2b-256 f606c33075b6acc2f97e4b8d90c321d23bed798af5b78fbf4347380e9a24c13f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page