Hi,
I have many flows that connect to various 365 resources (outlook, onedrive, excel and etc...).
All those are working under my credentials, and everything's working great!
The problem is, that once every while, the connections is broken and I have to manually connect to the portal and fix it.
The question is - is there way that I can do it programatically on a schedule? instead of having to connect and fix each and every (there are a lot) connections manually.
For a flow that needs access to your information you would definitely need to give the service account access to that information.
But in general MFA alone shouldn't require re-authentication of the connection just because the MFA has expired. The MFA is used at the point where you establish the OAUth connection. But wouldn't be needed again until the OAuth comes up for renewal, not the MFA. I believe the OAuth refresh token, which is used in place of the user ID and password, timesout at 90 days by default. There are settings in Azure AD that can shorten this. Your MFA implementation may have done that, but its not a requirement of MFA.
So in my case the flow needs to access my personal data on my mailbox and others like OneDrive. In that case that service account will need to have full access rights to those features... so that means that organization that work with MFA for all their users, will need to have duplicate accounts (private and a dedicated service account) for each employee...
am I missing anything?
Yes, you can do it with a service account. The easiest way to do that is to log in as the service account, edit the connections, and publish the flow. The service account will then be the maker and the connections will run in its context. This will require assigning a license to the service account since it will be running the flows.
@yuryk just over a year ago I had the same problem. In my case the connection to SharePoint was breaking every 1 hour and others would occasionally need fixing too. The fix I found (to Microsoft's surprise as they didn't suggest it) was to go into PowerApps and have a look at the Connections screen there. At the time I didn't normally go there because that screen is exactly the same as you get with Flow as they share the connections. Just for curiosity I did a "switch account" a couple of times there (I had already done it in Flow with no change in behaviour) and selected my account. An hour later I noticed back in Flow (as it then was) that the connection had refreshed after 1 hour and I was still connected successfully. I have had no problems since.
So give it a go and see if it also works for you.
Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.
Thx for the quick response.
The problem is that my user has MFA enforcement, which expires.
lets try another angle.
Any way I can use flows such as 'When and email is flagged' (or any other O365 action) with a service account that is not set for MFA?
right now i'm working on a flow that will create a To-Do task on flagged emails (there's a template, i know).
I am not aware of any way to do this using an automated API. Its also not a good idea since you would be embedding your user ID and password in any process that does that. Connections will automatically refresh the OAuth connection on a timed basis. Normally this works fine. But some things can interfere, for example when you change your password or when the underlying connection API changes. These are the kinds of events that make you re-authenticate manually. Since there isn't one specific cause its hard to even predict when it will happen much less figure out a way to handle it automatically.
Michael E. Gernaey
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492