pac auth
Manage how you authenticate to various services
Use the pac auth create command to connect to your tenant. Running pac auth create
creates an authentication profile on your machine. You can have multiple authentication profiles available. Having multiple authentication profiles is interesting when you work with multiple tenants. For instance, when your company uses multiple tenants (for development, production, and test) or when you're a consultant that works for multiple customers.
The pac auth create
command has a couple of helpful parameters:
The
--environment
parameter enables you to automatically connect to the right environment. If you omit the--environment
parameter, you're connected to the default environment, but with the--environment
parameter added to it, you can connect to a different one. You can use the environment ID, url, unique name, or partial name as the value.In environments where you don't have the ability to use an interactive experience, adding the
--deviceCode
parameter makes sure you can still connect. For example, in GitHub Codespaces, the--deviceCode
parameter automatically gets added when you runpac auth create
.
To connect to the HR-Dev
environment, you can use the following example:
pac auth create --environment "HR-Dev"
When you have multiple authentication profiles, you can easily switch using the pac auth list and pac auth select commands.
The pac auth list
command lists all authentication profiles on your machine. The pac auth select
command selects a different command.
To list all authentication profiles, use the following example:
pac auth list
Running the pac auth list
command returns all authentication profiles:
Index Active Kind Name Friendly Name Url User Cloud Type
[1] * UNIVERSAL Personal Productivity (Default) https://x.crm.dynamics.com/ user@contoso.onmicrosoft.com Public User
Select a different authentication profile using the index value.
pac auth select --index 2
Command | Description |
---|---|
pac auth clear | Clear all authentication profiles stored on this computer |
pac auth create | Create and store authentication profiles on this computer |
pac auth delete | Delete a particular authentication profile |
pac auth list | List the authentication profiles stored on this computer |
pac auth name | Name or rename an existing authentication profile |
pac auth select | Select which authentication profile should be active |
pac auth update | Update name or target environment of an existing authentication profile |
pac auth who | Display information about currently selected authentication profile |
Clear all authentication profiles stored on this computer
Create and store authentication profiles on this computer
The following examples show the use of the pac auth create
command.
This example will prompt you for credentials and connects to the tenant the credentials belong to.
pac auth create
Note
When running Power Platform CLI in Codespaces this will trigger a device code login.
This example will prompt you for credentials and connects to the Power Platform environment with environment id you specify.
pac auth create --environment < Your environment ID >
Tip
To find an environment id:
- Open Power Platform admin center and select the Environment you want to connect to. In the Details section, look for Environment ID
This example authenticates with your tenant and gives it the name MyOrg
.
pac auth create --name MyOrg
This example authenticates with your tenant, gives it the name MyOrg-SPN
and uses a service principal to do so. Don't forget to add the service principal to your environment.
pac auth create --name MyOrg-SPN --applicationId 00000000-0000-0000-0000-000000000000 --clientSecret $clientSecret --tenant 00000000-0000-0000-0000-000000000000
Optional: The application ID to authenticate with.
(Preview) Use Azure DevOps Federation for Service Principal Auth; requires --tenant and --applicationId arguments
This parameter requires no value. It's a switch.
Optional: The certificate disk path to authenticate with
Optional: The certificate password to authenticate with
Optional: The client secret to authenticate with
Optional: The cloud instance to authenticate with
Use one of these values:
Public
UsGov
UsGovHigh
UsGovDod
China
Use the Microsoft Entra ID Device Code flow for interactive sign-in.
This parameter requires no value. It's a switch.
Default environment (ID, url, unique name, or partial name).
(Preview) Use GitHub Federation for Service Principal Auth; requires --tenant and --applicationId arguments
This parameter requires no value. It's a switch.
Deprecated: This parameter is ignored.
Use Azure Managed Identity.
This parameter requires no value. It's a switch.
The name you want to give to this authentication profile (maximum 30 characters).
Note: The length of the name should be between 1 and 30
Optional: The password to authenticate with
Tenant ID if using application ID/client secret or application ID/client certificate.
Deprecated: Use --environment
instead.
Optional: The username to authenticate with; shows Microsoft Entra ID dialog if not specified.
For the cloud
parameter, the values to use map to these other common acronyms or names:
- GCC =
UsGov
- GCC High =
UsGovHigh
- DoD =
UsGovDod
Delete a particular authentication profile
pac auth delete --index 2
The index of the profile to be deleted
Note: The value must be an integer with minimum value of 1.
The name of the profile to be active
Note: The length of the name should be between 1 and 30
List the authentication profiles stored on this computer
Name or rename an existing authentication profile
The following example shows how to rename an auth profile. In this case, the profile with index 1 will be renamed to 'Contoso Dev'.
pac auth name --index 1 --name "Contoso Dev"
The index of the profile to be named/renamed
Note: The value must be an integer with minimum value of 1.
The name you want to give to this authentication profile (maximum 30 characters).
Note: The length of the name should be between 1 and 30
Select which authentication profile should be active
pac auth select --index 2
The index of the profile to be active.
Note: The value must be an integer with minimum value of 1.
The name of the profile to be active
Note: The length of the name should be between 1 and 30
Update name or target environment of an existing authentication profile
The following examples show the use of the pac auth update command.
This example shows how to update the auth profile with index 1 with the name Contoso Dev
and the environment URL https://contosodev.crm.dynamics.com
.
pac auth update --index 1 --name "Contoso Dev" --environment "https://contosodev.crm.dynamics.com"
This example shows how to update the auth profile with index 1 with the environment ID 00000000-0000-0000-0000-000000000000
.
pac auth update --index 1 --environment 00000000-0000-0000-0000-000000000000
The index of the profile to be named/renamed
Note: The value must be an integer with minimum value of 1.
Default environment (ID, url, unique name, or partial name).
The name you want to give to this authentication profile (maximum 30 characters).
Display information about currently selected authentication profile
Microsoft Power Platform CLI Command Groups
Microsoft Power Platform CLI overview