From d907dd8cff8e2950516dfeaf39f201f34b1114fa Mon Sep 17 00:00:00 2001 From: Tim Nowaczyk Date: Tue, 26 Mar 2024 12:07:47 -0400 Subject: [PATCH] Fix MSGraph UsernamePassword Authentication (#497) parsedmarc/pull/471 broke UsernamePassword authentication for me. This change fixes it. Co-authored-by: Tim Nowaczyk --- parsedmarc/cli.py | 5 +++++ parsedmarc/mail/graph.py | 1 + 2 files changed, 6 insertions(+) diff --git a/parsedmarc/cli.py b/parsedmarc/cli.py index 08da40f..60d9206 100644 --- a/parsedmarc/cli.py +++ b/parsedmarc/cli.py @@ -662,6 +662,11 @@ def _main(): else: logger.critical("password setting missing from the " "msgraph config section") + if "client_secret" in graph_config: + opts.graph_client_secret = graph_config["client_secret"] + else: + logger.critical("client_secret setting missing from the " + "msgraph config section") exit(-1) if opts.graph_auth_method == AuthMethod.DeviceCode.name: diff --git a/parsedmarc/mail/graph.py b/parsedmarc/mail/graph.py index f2fe299..2fc4364 100644 --- a/parsedmarc/mail/graph.py +++ b/parsedmarc/mail/graph.py @@ -59,6 +59,7 @@ def _generate_credential(auth_method: str, token_path: Path, **kwargs): elif auth_method == AuthMethod.UsernamePassword.name: credential = UsernamePasswordCredential( client_id=kwargs['client_id'], + client_credential=kwargs['client_secret'], disable_automatic_authentication=True, username=kwargs['username'], password=kwargs['password'],