pac auth

Manage how you authenticate to various services

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 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:

  1. Open Power Platform admin center and select an 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.

--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).

--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

The resource URL to connect to

--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 a positive integer.

--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 a positive integer.

--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 a positive integer.

--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 a positive integer.

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).

See also

Microsoft Power Platform CLI Command Groups
Microsoft Power Platform CLI overview