Support Questions

Find answers, ask questions, and share your expertise
Celebrating as our community reaches 100,000 members! Thank you!

ConsumeIMAP with OAuth2accesstokenprovider works when "run once" only



I have a ConsumeIMAP processor downloading emails from office 365 mailbox using StandardOAuth2AccessTokenProvider.

Here is a simple structure, consisting of few processors, including custom one. When testing various scenarios I also removed my custom processor to make sure my problem is not caused by this.

The thing is, that when testing and starting ConnsumeIMAP via "run once" option, it works perfectly and it gives me my 10 emails as set in Fetch Size.

But when I start processor using Start option so it uses cron frequency 2 minutes, it returns only one email and the rest only when I stop the ConsumeIMAP processor. I tried to schedule to 5, 10, 15 minutes, but without effect. Also tried for accesstokenprovider processor various setting in refresh window property from 0 s to 60 s, but also without any effect.

Also, after some time, and only sometimes, I get Authentization fail error, see below. When I stop the processor and use "run once", it starts to work immediately as I already mentioned above.

Asked IT to check logs on exchange server, but there is nothing.

I'm a bit desperate by now, as I googled, chatgpted a lot, so you guy are my last chance before I get mad.

Thanks for all suggestions you might have.


Here are parameters of ConsumeIMAP and StandardOAuth2AccessTokenProvider:




org.apache.nifi.processor.exception.ProcessException: Failed to receive messages from Email server: [javax.mail.AuthenticationFailedException - AUTHENTICATE failed. at at at at at org.apache.nifi.processor.AbstractProcessor.onTrigger( at org.apache.nifi.controller.StandardProcessorNode.onTrigger( at org.apache.nifi.controller.tasks.ConnectableTask.invoke( at org.apache.nifi.controller.scheduling.QuartzSchedulingAgent$ at org.apache.nifi.engine.FlowEngine$ at java.util.concurrent.Executors$ at at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201( at java.util.concurrent.ScheduledThreadPoolExecutor$ at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: javax.mail.AuthenticationFailedException: AUTHENTICATE failed. at com.sun.mail.imap.IMAPStore.protocolConnect( at javax.mail.Service.connect( at javax.mail.Service.connect( at javax.mail.Service.connect( at org.springframework.integration.mail.AbstractMailReceiver.connectStoreIfNecessary( at org.springframework.integration.mail.AbstractMailReceiver.openFolder( at org.springframework.integration.mail.AbstractMailReceiver.receive( at