Microsoft PowerApps - Bypass Consent - PowerShell
This week I was developing a Power App and was faced with an issue when adding the Data connector for Office365Users. The reason why I was using the Data connector was to create a Text field that had the function User().FullName so that I could then use that variable in a PowerAutomate flow.run().
Problem
It worked fine when running the App with my account, but as soon as another user used it they were faced with the following window:
I thought to myself, there has to be a way to consent for users. Luckily there was a way to fix this via PowerShell.
Solution
Start by opening up PowerShell and run it as Administrator on your Windows device. Next, run the following commands:
PowerShell Command
// Install PowerApps Administration Module
Install-Module -Name Microsoft.PowerApps.Administration.PowerShell
Once it has installed, you will want to connect to PowerApps using:
Add-PowerAppsAccount
Next, you are going to want to find your AppName and your EnvironmentName. You can do this by running the following command
// Find PowerApps Apps
Get-AdminPowerApp | Select-Object DisplayName, EnvironmentName, AppName
This will list off all of the Apps you have access too. Your actual PowerApps name will be DisplayName. You will want to note the corresponding EnvironmentName and AppName
Then you will want to use the following command to grant consent to all users to bypass the consent window seen above
// Grant consent to all users for PowerApp app
Set-AdminPowerAppistoBypassConsent -EnvironmentName <EnvironmentName> -AppName <AppName>
If correctly used, you will get a StatusCode "200", StatusDescription "OK"
Summary
When using Data connectors in PowerApps, if consent bypass has not been enabled, users will be faced with consenting the app to access their Office 365 information. If you utilize the PowerShell PowerApps cmdlet, you can set a bypass per App.