parsedmarc
parsedmarc copied to clipboard
MSGraph Folder not found
I am using MSGraph with client secret and am trying to pull from a shared mailbox in o365.
My Config is:
[general] save_aggregate = True log_file = /var/log/parsedmarc debug = True silent = False
[mailbox] reports_folder = Inbox watch = True test = True batch_size = 5
[msgraph] auth_method = ClientSecret client_id = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX client_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXX tenant_id = XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX mailbox = [email protected] user = [email protected] allow_unencrypted_storage = True token_file = /opt/parsedmarc/.pmarctoken
[elasticsearch] hosts = https://[email protected]:9200
And receive this error:
2023-05-22 14:40:27,963 - INFO - [cli.py:753] - Starting parsedmarc 2023-05-22 14:40:28,933 - ERROR - [cli.py:985] - Mailbox Error Traceback (most recent call last): File "/opt/parsedmarc/.local/lib/python3.10/site-packages/parsedmarc/cli.py", line 968, in _main reports = get_dmarc_reports_from_mailbox( File "/opt/parsedmarc/.local/lib/python3.10/site-packages/parsedmarc/init.py", line 1085, in get_dmarc_reports_from_mailbox messages = connection.fetch_messages(reports_folder, batch_size=batch_size) File "/opt/parsedmarc/.local/lib/python3.10/site-packages/parsedmarc/mail/graph.py", line 145, in fetch_messages folder_id = self._find_folder_id_from_folder_path(folder_name) File "/opt/parsedmarc/.local/lib/python3.10/site-packages/parsedmarc/mail/graph.py", line 217, in _find_folder_id_from_folder_path return self._find_folder_id_with_parent(folder_name, None) File "/opt/parsedmarc/.local/lib/python3.10/site-packages/parsedmarc/mail/graph.py", line 234, in _find_folder_id_with_parent raise RuntimeError(f"folder {folder_name} not found") RuntimeError: folder Inbox not found
The inbox folder does exist. The application registration has the Mail.ReadWrite application permission as well as the Mail.ReadWrite, Mail.ReadWrite.Shared and User.Read delegated permissions and have been admin consented for the tenant.
Further, If I test with a non-shared mailbox, the Inbox will be found, but if the folder is changed to a non-default folder it will result in the same error. All folders are in the root of the hierarchy and are listed when checking them with the ExchangeOnline powershell module command
Get-MailboxFolderStatistics -Identity [email protected] | select Name, FolderId, FolderPath
Am I missing something?
Don't know if it can help but I had a similar issue with a mailbox that was localized. the term Inbox was wrong for me as it was modified to my language term.
Unfortunately it doesn't. The mailboxes are english so Inbox is correct. The Inbox not being found is just on shared mailboxes, other normal mailboxes don't have an issue with Inbox. Custom folders aren't found either in all mailboxes.
Thank you for the suggestion though.
I found that the folder names are also case sensitive. I haven't tested with the main Inbox folder but have made separate folders under the root hierarchy for both the reports and archive folders, and this is working without issue. This in a shared mailbox.
here is my config that works
[mailbox]
watch = True
batch_size = 1000
reports_folder = Inbox
[msgraph]
auth_method = ClientSecret
client_id = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
client_secret = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
tenant_id = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mailbox [email protected]
If it can help
M365's Outlook mailbox inbox will change according to the account's local language settings. For example, it will be 'inbox' in English and '收信夾' in Chinese. So, if your default language is not English, you cannot specify 'inbox'.