In my previous post, Power Apps Code Apps – Trigger a Power Automate Flow, I walked through adding and calling a cloud flow from a code app.
On a different project, I hit an authorization error running npx power-apps list-flows. Lets look at what caused it and the two commands that fixed it.
Reason :
- I ran
npx power-apps list-flowsin a code app folder to find the flow ID before adding it. The command failed with an authorization error instead of listing the flows in the environment.

- At this point I already had a valid
pac authsession. Runningpac auth listshowed the correct account and environment. That is what threw me. - The
pacCLI and thenpx power-appsCLI look similar, but they do not share the same signed-in identity.
Note: Per the official docs,
npx power-appsauthentication is independent ofpac auth. Signing in with one does not sign you in to the other. See Sign in and manage accounts with the Power Apps CLI.
- The
npx power-appsCLI reads the targetenvironmentIdfrom the project’spower.config.json. - In my case, the
power-appsCLI still held a stale identity from another tenant. That account did not have access to the target environment, so everynpx power-appscommand failed with the authorization error.
Fix :
The fix is two commands. Lets sign out of the power-apps CLI, then sign back in with the account that has access to the target environment.
- Sign out of all accounts in the
power-appsCLI cache.
npx power-apps logout
- Sign in again. A browser window opens for interactive login.
npx power-apps login

- Now re-run the original command.
list-flowsreturns the solution-aware flows in the environment as expected.

Things Worth Knowing
- The
power-appsCLI picks the target environment from the current folder’spower.config.json. There is no separateset-envcommand. So even after a clean login, the authorization error comes back if the signed-in account has no access to that environment ID. Fix the account, or fix the environment ID. Not both at once. - The npm-based
power-appsCLI is the recommended path for Power Apps Code Apps going forward. Thepac codecommands remain for other Power Platform work.
📖 Official documentation: Sign in and manage accounts with the Power Apps CLI
🙂



Leave a Reply