Skip to content

Commit

Permalink
initial commit, updated requirements.txt, initial design
Browse files Browse the repository at this point in the history
  • Loading branch information
phlamprecht committed Sep 25, 2024
1 parent c40367f commit a6aa563
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Binary file modified requirements.txt
Binary file not shown.
48 changes: 48 additions & 0 deletions sharepoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""module to sync files with sharepoint site"""

from O365 import Account
from decouple import config


class _sharepoint:
def __init__(self) -> None:
client_id = config("CLIENTID")
client_secret = config("CLIENTSECRET")
tenant_id = config("TENANTID")
account = self._authenticate(client_id, client_secret, tenant_id)
self.storage = account.storage()

def _authenticate(self, client_id: str, client_secret: str, tenant_id: str):
"""authenticate with Micosoft Graph API
Args:
client_id (str): microsoft client id
client_secret (str): microsoft client secret
tenant_id (str): microsoft tenant id
Returns:
account: O365 account object if authentication was successful
"""
credentials = (client_id, client_secret)
try:
account = Account(
credentials, auth_flow_type="credentials", tenant_id=tenant_id
)
if account.authenticate():
print("Authenticated!")
return account
except ValueError as e:
print(e)
return None

def download_file(self):
"""_summary_"""
# File to download, and location to download to
dl_path = "/path/to/download"
f_name = "myfile.xlsx"

def upload_file(self):
"""_summary_"""
# File to upload, and location to upload to
ul_path = "/path/to/upload"
f_name = "myfile.xlsx"

0 comments on commit a6aa563

Please sign in to comment.