SOLVED
Home

Uploading file via PowerApps into SharePoint document library

%3CLINGO-SUB%20id%3D%22lingo-sub-284767%22%20slang%3D%22en-US%22%3EUploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284767%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EI'm%20hoping%20someone%20has%20encountered%20the%20situation%20I'm%20in%20and%20were%20able%20to%20come%20up%20with%20a%20successful%20solution.%20%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EI%20currently%20have%20a%20PowerApps%20application%20that%20uploads%20a%20file%20to%20a%20Sharepoint%20document%20library%20using%20MS%20Flow.%20The%20Flow%26nbsp%3Bwas%20also%20set%20up%20to%26nbsp%3Buse%20a%20service%20account%20when%20accessing%20SharePoint.%20However%2C%20whenever%20the%20Flow%20is%20triggered%2C%20the%20file%20is%20uploaded%20using%20the%20credential%20of%20the%20user%20that%20was%20logged%20into%20the%20PowerApps%20app.%20I%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eneed%20to%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Elock%20down%20the%20Sharepoint%20document%20library%20so%20the%20same%20user%20only%20has%20read-only%20access%20to%20it.%20The%20file%20needs%20to%20be%20uploaded%20by%20the%20Flow%20author%20(service%20account)%20instead%20of%20the%20user.%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EIf%20anyone%20has%20any%20suggestions%20that%20I%20can%20try%20to%20get%20this%20to%20work%2C%20it'd%20be%20greatly%20appreciated.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EFrancis%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-284767%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Flow%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerApps%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-285131%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-285131%22%20slang%3D%22en-US%22%3E%3CP%3EWhile%20that%20method%20still%20applied%2C%20the%20SharePoint%20HTTP%20action%20makes%20things%20considerably%20simpler.%20You%20still%20use%20the%20HTTP%20trigger%20as%20described%2C%20but%20the%20service%20account%20will%20use%20the%20SharePoint%20HTTP%20action%20and%20no%20more%20app%20principles%2Fsecret%2Ftoken%20config%20needed%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284956%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284956%22%20slang%3D%22en-US%22%3EWell%20if%20that%20don%E2%80%99t%20you%20can%20always%20get%20file.%20Create%20file%20from%20that%20get%20action%20then%20delete%20old%20file%20from%20get%20action%20I%E2%80%99d%20and%20that%20should%20work%20instead%20if%20the%20move%20takes%20create%20name%20across.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284955%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284955%22%20slang%3D%22en-US%22%3E%3CP%3ELol%2C%20that's%20exactly%20what%20I%20ended%20up%20doing%2C%20well%20trying%20anyways.%20Just%20need%20to%20confirm%20now%20that%20the%20file%20moved%20by%20the%20file%20property%20update%20trigger%20shows%20up%20as%20being%20moved%20by%20the%20service%20account.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20all%20your%20suggestions.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284953%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284953%22%20slang%3D%22en-US%22%3EThe%20http%20request%20was%20first%20thing%20that%20came%20to%20my%20mind%20but%20it%E2%80%99s%20a%20pita%20%3A).%20I%20guess%20the%20question%20is%20do%20you%20make%20use%20of%20the%20files%20in%20the%20powerapp%20or%20is%20it%20just%20a%20submission%20form%3F%20If%20you%20aren%E2%80%99t%20getting%20return%20data%20immediately%20in%20the%20app%20you%20could%20just%20rig%20it%20up%20where%20you%20dump%20the%20file%20to%20a%20temporary%20file%20location%20and%20just%20have%20another%20flow%20owned%20by%20the%20system%20account%20with%20a%20%E2%80%9Cnew%20item%E2%80%9D%20trigger%20moves%20the%20files%20into%20the%20final%20destination%20library.%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284828%22%20slang%3D%22en-US%22%3ERe%3A%20Uploading%20file%20via%20PowerApps%20into%20SharePoint%20document%20library%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284828%22%20slang%3D%22en-US%22%3E%3CP%3EYou%20could%20look%20into%20using%20a%20Flow%20triggered%20via%20HTTP%20Request%26nbsp%3Band%20configuring%20it%20to%20use%20the%20SharePoint%20app%20model%20for%20authentication.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20article%20linked%20below%20discusses%20setting%20permissions%2C%20but%20the%20key%20steps%20for%20you%20would%20be%20registering%20a%26nbsp%3B%20SharePoint%20App%2C%26nbsp%3Bthe%20Get%20Access%20Token%20piece%26nbsp%3Band%20then%20using%20the%20bearer%20token%20in%20Flow%20to%20upload%20the%20document%20via%20a%20REST%20call.%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20title%3D%22https%3A%2F%2Fnoellawlor.wordpress.com%2F2018%2F01%2F18%2Fsetting-sharepoint-item-list-permissions-with-flow%2F%22%20href%3D%22https%3A%2F%2Fnoellawlor.wordpress.com%2F2018%2F01%2F18%2Fsetting-sharepoint-item-list-permissions-with-flow%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fnoellawlor.wordpress.com%2F2018%2F01%2F18%2Fsetting-sharepoint-item-list-permissions-with-flow%2F%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Francis Lopez
New Contributor

I'm hoping someone has encountered the situation I'm in and were able to come up with a successful solution.

 

I currently have a PowerApps application that uploads a file to a Sharepoint document library using MS Flow. The Flow was also set up to use a service account when accessing SharePoint. However, whenever the Flow is triggered, the file is uploaded using the credential of the user that was logged into the PowerApps app. I need to lock down the Sharepoint document library so the same user only has read-only access to it. The file needs to be uploaded by the Flow author (service account) instead of the user. 

 

If anyone has any suggestions that I can try to get this to work, it'd be greatly appreciated.

 

Francis

5 Replies

You could look into using a Flow triggered via HTTP Request and configuring it to use the SharePoint app model for authentication.

 

The article linked below discusses setting permissions, but the key steps for you would be registering a  SharePoint App, the Get Access Token piece and then using the bearer token in Flow to upload the document via a REST call. 

https://noellawlor.wordpress.com/2018/01/18/setting-sharepoint-item-list-permissions-with-flow/

 

Solution
The http request was first thing that came to my mind but it’s a pita :). I guess the question is do you make use of the files in the powerapp or is it just a submission form? If you aren’t getting return data immediately in the app you could just rig it up where you dump the file to a temporary file location and just have another flow owned by the system account with a “new item” trigger moves the files into the final destination library.

Lol, that's exactly what I ended up doing, well trying anyways. Just need to confirm now that the file moved by the file property update trigger shows up as being moved by the service account.

 

Thanks for all your suggestions. 

Well if that don’t you can always get file. Create file from that get action then delete old file from get action I’d and that should work instead if the move takes create name across.

While that method still applied, the SharePoint HTTP action makes things considerably simpler. You still use the HTTP trigger as described, but the service account will use the SharePoint HTTP action and no more app principles/secret/token config needed

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies