When using Power Apps and connecting to an external source, such as SharePoint, a database, or other connection, your users will be prompted to allow the connections the first time they load the app.
While this is recommended for standalone apps, in many cases, we want to embed the Power App into a SharePoint page, in which case we don't want to prompt the user.
Fortunately, we can turn this off! I've found many variations of these steps. It depends on how your environment is set up. This is what worked for me. I ran this from the Windows PowerShell ISE run as administrator.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force dir . | Unblock-File Install-Module -Name Microsoft.PowerApps.Administration.PowerShell Install-Module -Name Microsoft.PowerApps.PowerShell -AllowClobber Import-Module Microsoft.Online.SharePoint.Powershell -Verbose Connect-SPOService -Url https://<<your tenant>>-admin.sharepoint.com Set-AdminPowerAppApisToBypassConsent -AppName <<GUID>>
- Set the Execution Policy to allow us to run the PowerShell. Accept the prompts.
- Install the Power Apps modules. Accept the prompts.
- Import the SharePoint PowerShell module.
- Connect to the tenant admin site. You'll be prompted to authenticate.
Set-AdminPowerAppAPIsToBypassConsentis the command that applies the change. Pass in the AppName (this is the App ID that can be found on the App Details page)
- I was prompted for the environment name, which can be found by running
Get-AdminPowerAppEnvironment, and it will return the default environment name. Copy the value to be used for the Environment parameter when prompted.