pac auth
Manage how you authenticate to various services
Connect to your tenant
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
.
Example
To connect to the HR-Dev
environment, you can use the following example:
pac auth create --environment "HR-Dev"
Switch to another authentication profile
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.
pac auth list
Example
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
Commands
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 |
pac auth clear
Clear all authentication profiles stored on this computer
pac auth create
Create and store authentication profiles on this computer
Examples
The following examples show the use of the pac auth create
command.
Basic Create
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.
Environment Create
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
Named Create
This example authenticates with your tenant and gives it the name MyOrg
.
pac auth create --name MyOrg
Named Create with Service Principal
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 Parameters for auth create
--applicationId
-id
Optional: The application ID to authenticate with.
--azureDevOpsFederated
-adof
(Preview) Use Azure DevOps Federation for Service Principal Auth; requires --tenant and --applicationId arguments
This parameter requires no value. It's a switch.
--certificateDiskPath
-cdp
Optional: The certificate disk path to authenticate with
--certificatePassword
-cp
Optional: The certificate password to authenticate with
--clientSecret
-cs
Optional: The client secret to authenticate with
--cloud
-ci
Optional: The cloud instance to authenticate with
Use one of these values:
Public
UsGov
UsGovHigh
UsGovDod
China
--deviceCode
-dc
Use the Microsoft Entra ID Device Code flow for interactive sign-in.
This parameter requires no value. It's a switch.
--environment
-env
Default environment (ID, url, unique name, or partial name).
--githubFederated
-ghf
(Preview) Use GitHub Federation for Service Principal Auth; requires --tenant and --applicationId arguments
This parameter requires no value. It's a switch.
--kind
-k
Deprecated: This parameter is ignored.
--managedIdentity
-mi
Use Azure Managed Identity.
This parameter requires no value. It's a switch.
--name
-n
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
--password
-p
Optional: The password to authenticate with
--tenant
-t
Tenant ID if using application ID/client secret or application ID/client certificate.
--url
-u
Deprecated: Use --environment
instead.
--username
-un
Optional: The username to authenticate with; shows Microsoft Entra ID dialog if not specified.
Remarks
For the cloud
parameter, the values to use map to these other common acronyms or names:
- GCC =
UsGov
- GCC High =
UsGovHigh
- DoD =
UsGovDod
pac auth delete
Delete a particular authentication profile
Example
pac auth delete --index 2
Optional Parameters for auth delete
--index
-i
The index of the profile to be deleted
Note: The value must be an integer with minimum value of 1.
--name
-n
The name of the profile to be active
Note: The length of the name should be between 1 and 30
pac auth list
List the authentication profiles stored on this computer
pac auth name
Name or rename an existing authentication profile
Example
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"
Required Parameters for auth name
--index
-i
The index of the profile to be named/renamed
Note: The value must be an integer with minimum value of 1.
--name
-n
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
pac auth select
Select which authentication profile should be active
Example
pac auth select --index 2
Optional Parameters for auth select
--index
-i
The index of the profile to be active.
Note: The value must be an integer with minimum value of 1.
--name
-n
The name of the profile to be active
Note: The length of the name should be between 1 and 30
pac auth update
Update name or target environment of an existing authentication profile
Examples
The following examples show the use of the pac auth update command.
Update auth profile with environment URL
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"
Update auth profile with environment ID
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
Required Parameters for auth update
--index
-i
The index of the profile to be named/renamed
Note: The value must be an integer with minimum value of 1.
Optional Parameters for auth update
--environment
-env
Default environment (ID, url, unique name, or partial name).
--name
-n
The name you want to give to this authentication profile (maximum 30 characters).
pac auth who
Display information about currently selected authentication profile
See also
Microsoft Power Platform CLI Command Groups
Microsoft Power Platform CLI overview