web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Add-PowerAppsAccount u...
Power Apps
Unanswered

Add-PowerAppsAccount using ClientSecret in PowerApps PowerShell module

(0) ShareShare
ReportReport
Posted on by 11

I want to use PowerApps PowerShell module to set role assignments, but I want an application to sign in using  Add-PowerAppsAccount , and not a user. I saw that ApplicationId and ClientSecret can be used to connect, which I tried. There also exists an application user for the same application in my environment and system admin role is assigned to that app user.  

 

I ran the following to connect:

Add-PowerAppsAccount -ApplicationId xxx -ClientSecret xxx -TenantID xxx -Audience my-environment-url

 

It shows no error while establishing the connection, and $global:currentSession returns loggedIn = true and it also returns some userId (which objectID of the application user) along with other details.  Now when I run Set-AdminPowerAppRoleAssignment cmdlet and pass required parameters. AppName is the ID of the powerapp which I want to share, EnvironmentName is Id of the environment and PrincipalObjectId is ID of the user from Azure AD to whom I want to assign the CanEdit role. The command fails with an error like shown in the image below. Is there anything that I'm missing here? Or application user cannot perform this command? Basically I'd like to share access with other users using application context in PowerShell, i.e I do not want to store admin credentials or ask him to login. I want to use client credentials for connection, and that connection should be authorized to set role assignments. 

 

Edit: The app for which I want role assignments has been imported as a part of solution by an application user. Hence, the app's owner is an application user. When I login to Add-PowerAppAccount interactively using admin credentials and run Get-AdminPowerApp to get list of all apps across all environments, I see the app which was imported by the application user. But when I use clientSecret and applicationId to login, and then run Get-AdminPowerApp or Get-PowerApp, I do not see it. I guess this particular case should work as the logged in user ID is same as the application user who is owner of that app, but it doesn't. 

 

Edit: I tried Get-PowerApp -Verbose while logged in as application user.  I get the the error as shown in the image below. I guess it tries to find the application user in Azure AD, but the application user is not there. screenshot2.png

screenshot.png

I have the same question (0)
  • aspassov Profile Picture
    6 on at

    Hi @rohannevrikar , did you get any news on this or were you able to resolve this? I'm currently facing the same issue

  • rohannevrikar Profile Picture
    11 on at

    Hi @aspassov, I got in touch with Microsoft support regarding this. They said that this functionality is not supported yet. We can't use ClientSecret in this module. Current user's context after logging in with ClientSecret is that of an application user, but the application user is a tricky thing in PowerApps as licensing thing would mess up, that's what the customer executive told me, which makes sense. 

  • antonioscoelho Profile Picture
    2 on at

    Hi, we are facing the same problem using the ClientId/ClientSecret. Any news on when this authentication method will be available to be used?

     

  • rohannevrikar Profile Picture
    11 on at

    Hi @antonioscoelho, I had asked Microsoft support the same question and they indirectly told me not to keep my hopes high. Licensing part is tricky here so they have not committed any timeline while I was working with them on this. 

  • aspassov Profile Picture
    6 on at

    As a workaround (setting owner of an app imported by an application user), I added a Power Automate Flow which achieves the same result. The HTTP triggered flow is then called from my release pipeline. This way the issue is resolved until the PowerShell command is fixed.

  • hackondor Profile Picture
    37 on at

    Hi @aspassov we're facing the same issue can you elaborate (The call from the release pipeline) how did you achieve that ? 

    Thank's

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @rohannevrikar did you find a solution for the issue, is it always impossible to use the Add-PowerAppsAccount using ClientSecret in PowerApps PowerShell module ?

  • rohannevrikar Profile Picture
    11 on at

    Hi @Anonymous. I didn't pursue it any further after concluding with MS support that they aren't planning on making this happen in near future because of certain complications. It has been a while since I worked on anything related to this so I don't know if there is any other workaround out there. As my use case was related to CDS back then, I was able to work with CDS SDK. 

  • Devikumari Krishna Profile Picture
    988 Super User 2024 Season 1 on at

    Hi @rohannevrikar ,

     

    This is not going to be possible at the moment. I checked in Wave release for 2022 this functionality is not available. We have to wait until it gets released.

     

    -------------------------------------------------------------------

    Please give kudos if the information was helpful.

     

    My Blogs: https://d365topicsbydk.com

     

    Regards

    Devi

     

  • YYCRMGuy Profile Picture
    9 on at

    Has anyone successfully done this yet? Would like to work around an issue with the DevOps Pipelines deactivating Flows during deployment, by adding a PowerShells script to Activate the Flows in the solution.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard