A simple solution to read mails from a Office 365 mail box using OAuth2 Authentication. The solution retrieves an access token via the Azure API and then uses that token to read mails from a specified mailbox. Please note that OAuth2 needs to be configured on your Azure/Office365 account and necessary permissions needs to be applied for this to work
Ensure that you set up the OAuth2 configuration on your Azure/Office365 account correctly in order for this to work. you can try the following tutorial
You will need:
- TenantID
- ClientID
- ClientSecret
- EmailAddress that has IMAP enabled and correct permissions
Add the details into the variables declared above in the OAuth2Mail function:
- TenantID
- ClientID
- ClientSecret
- EmailAddress
Add your logic to the function to manipulate/use the email as required. You can remove the 'YourLogicGoesHere' component as it is a placeholder.
If you get an error like NO AUTHENTICATE, it is likely that you need to check your permissions or Azure setup as there might be something that was missed.
For questions please ask the Linx community.