Ever since 2016, when Power Apps was first released, I’ve found it to be a very useful tool. I’m certainly not alone in feeling this way, as for a customer’s recent project, they wanted to Convert Power Apps screens to PDF. I got this working for them, but when the App was deployed, they started getting an authentication prompt for each user.
So, what is happening? Why is this authentication prompt popping up for users, but everything worked fine for me?
The answer is short and easy to explain. Connectors’ credentials are not saved alongside the Power App. As a result, upon first use of a Power App, each user needs to manually authenticate against all connectors used in the App. This means setting up a separate, or shared account, for each user in each connector, very inconvenient.
As sharing credentials is not a best practice and connector providers (including Muhimbi) are not in control of this aspect of the way Power Apps works, may I ask for 1 minute of your time to vote for this Flow idea.
Luckily, there is a good workaround, which is detailed below. In summary, we ‘decouple’ the flow from the Power App by writing to SharePoint from the App. We then use the full version of Power Automate to attach the Flow, which does all the work, to the SharePoint list or library. Flows associated with SharePoint do not require each user to authenticate. Easy and convenient. In a future post I will explain how to apply the same principle without using SharePoint as an intermediate.
When sharing my Power Apps with End users, this was the message I received:
‘Data permissions: Make sure your users have access to the data used in your app, including gateways, APIs, connectors, and entities‘.
In the Power Automate (Flow) portal, I could not find an option to ‘Share the Connection‘ or manage ‘Run only users‘ and that was indeed the cause of the problem.
Now that we understand the problem, lets quickly have a look at the Power Apps and Power Automate (Flow).
Power Apps – Canvas APP with a Single Text-Input(TextInput1) and Button(Button1)
- On the Button, ‘OnSelect‘ property, I have associated a Power Automate(Flow) and used the ‘Run‘ function and passed the TextInput1.Text. ‘ConvertResponsetoPDF.Run(TextInput1.Text)‘.
Power Automate – To Convert Data returned by Power Apps to PDF.
- Use the Power Apps Trigger.
- Initialized variable (Feedback) of Type String and select on ‘Ask in Power Apps‘. (This is the variable that need passing between your Power Apps).
- Compose action – This will hold our HTML.
- Muhimbi ‘Convert HTML to PDF‘ action – Passed the output of the Compose action to Convert HTML to PDF.
- SharePoint ‘Create File‘ action – Create a file in SharePoint.
The Solution? Use The Decoupled or Indirect approach in Power Automate (Flow)
The ‘Decoupled’ or ‘Indirect’ approach, is to create a Flow in the Document Library to which we write the HTML file and that Flow should be set to an automatic trigger, such as ‘When a File is Created in a folder’.
If you observe the screenshot below, I have removed the ‘Muhimbi Convert HTML to PDF‘ action and instead of writing PDF to SharePoint I am writing the HTML file.
Note: In the SharePoint ‘Create File’ action, I using the ‘Concat’ function in the ‘File Name‘ to create unique file names in SharePoint.
First decoupled Power Automate(Flow)
Second decoupled Power Automate(Flow)
- Lets create another Power Automate(Flow) and add the Conversion Logic. Note: The Folder path for ‘When a File is Created in a folder‘ should be exactly the same of the previous Power Automate(Flow) ‘Create file‘ action.
- The new Power Automate(Flow) would be a simple ‘Three Step’ Flow, as shown below.
Now when you End user launches the APP, he will not get the Muhimbi Sign-in Prompt.
Fill in the details in the Power App, click on the Submit button and after a few seconds, you should have a PDF in your SharePoint Folder.
Subscribe to this blog for the latest updates about SharePoint Online, Microsoft Flow, Power Apps and document conversion and manipulation.