예제 #1
0
    def setUp(self) -> None:
        """Set up the `MicrosoftGraphClient` Client."""

        scopes = [
            'Calendars.ReadWrite', 'Files.ReadWrite.All', 'User.ReadWrite.All',
            'Notes.ReadWrite.All', 'Directory.ReadWrite.All', 'User.Read.All',
            'Directory.Read.All', 'Directory.ReadWrite.All'
        ]

        # Initialize the Parser.
        config = ConfigParser()

        # Read the file.
        config.read('config/config.ini')

        # Get the specified credentials.
        client_id = config.get('graph_api', 'client_id')
        client_secret = config.get('graph_api', 'client_secret')
        redirect_uri = config.get('graph_api', 'redirect_uri')

        # Initialize the Client.
        graph_client = MicrosoftGraphClient(
            client_id=client_id,
            client_secret=client_secret,
            redirect_uri=redirect_uri,
            scope=scopes,
            credentials='config/ms_graph_state.jsonc')

        self.client = graph_client
예제 #2
0
def upload(item_path, upload_type, file_path):
    # Initialize the Graph Client.
    graph_client = MicrosoftGraphClient(
        client_id=client_id,
        client_secret=client_secret,
        redirect_uri=redirect_uri,
        scope=scopes,
        credentials='config/ms_graph_state.jsonc')

    # Login
    graph_client.login()

    # Grab the Drive Item services
    drive_item_services = graph_client.drive_item()

    # Create an upload session
    upload_session = drive_item_services.create_upload_session(
        item_path=item_path, item=upload_type)

    drive_item_services.upload_large_file(upload_session['uploadUrl'],
                                          file_path)
# Initialize the Parser.
config = ConfigParser()

# Read the file.
config.read('config/config.ini')

# Get the specified credentials.
client_id = config.get('graph_api', 'client_id')
client_secret = config.get('graph_api', 'client_secret')
redirect_uri = config.get('graph_api', 'redirect_uri')

# Initialize the Client.
graph_client = MicrosoftGraphClient(client_id=client_id,
                                    client_secret=client_secret,
                                    redirect_uri=redirect_uri,
                                    scope=scopes,
                                    credentials='config/ms_graph_state.jsonc')

# Login to the Client.
graph_client.login()

# Define a valid User ID.
user_id = '8bc640c57cda25b6'

# Define a mail Item ID.
mail_id = 'AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb_dak68rN7703u' + \
          'ffQcAFNKsLOjbGUuHHmYnyKdJiAAAAgEhAAAAFNKsLOjbGUuHHmYnyKdJiAAFBMTneQAAAA=='

# Define a mail item ID with Attachments.
mail_id_with_attachments = 'AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgBGAAADpjqwNb+' + \
# Initialize the Parser.
config = ConfigParser()

# Read the file.
config.read('configs/config.ini')

# Get the specified credentials.
client_id = config.get('graph_api', 'client_id')
client_secret = config.get('graph_api', 'client_secret')
redirect_uri = config.get('graph_api', 'redirect_uri')

# Initialize the Client.
graph_client = MicrosoftGraphClient(
    client_id=client_id,
    client_secret=client_secret,
    redirect_uri=redirect_uri,
    scope=scopes,
    credentials='configs/ms_graph_state.jsonc'
)

# Login to the Client.
graph_client.login()

# Define a valid User ID.
user_id = '8bc640c57cda25b6'

# Define a folder ID.
folder_id = 'AQMkADAwATZiZmYAZC1hMDI2LTE3NTgtMDACLTAwCgAuAAADpjqwNb_d' + \
            'ak68rN7703uffQEAFNKsLOjbGUuHHmYnyKdJiAAFAP8ORwAAAA=='

# Grab the Personal Contacts Service.
예제 #5
0
    'Calendars.ReadWrite'
]

# Initialize the Parser.
config = ConfigParser()

# Read the file.
config.read('configs/config.ini')

# Get the specified credentials.
client_id = config.get('graph_api', 'client_id')
client_secret = config.get('graph_api', 'client_secret')
redirect_uri = config.get('graph_api', 'redirect_uri')

# Initialize the Client.
graph_client = MicrosoftGraphClient(
    client_id=client_id,
    client_secret=client_secret,
    redirect_uri=redirect_uri,
    scope=scopes,
    credentials='configs/ms_graph_state.jsonc'
)

# Login to the Client.
graph_client.login()

# Grab the Event Object.
calendar_object = graph_client.calendar()


pprint(calendar_object.get_all_calendars())
예제 #6
0
# Initialize the Parser.
config = ConfigParser()

# Read the file.
config.read('configs/config.ini')

# Get the specified credentials.
client_id = config.get('graph_api', 'client_id')
client_secret = config.get('graph_api', 'client_secret')
redirect_uri = config.get('graph_api', 'redirect_uri')

# Initialize the Client.
graph_client = MicrosoftGraphClient(client_id=client_id,
                                    client_secret=client_secret,
                                    redirect_uri=redirect_uri,
                                    scope=scopes,
                                    credentials='configs/ms_graph_state.jsonc')

# Login to the Client.
graph_client.login()

# Grab the User Services.
user_services = graph_client.users()

# List the Users.
pprint(user_services.list_users())

# Grab the Drive Services.
drive_services = graph_client.drives()