How to Create a Passwords for Users in a Scratch Orgs

ליאור נכתב על ידי ליאור לביא, עודכן בתאריך 09/11/2023

Sometimes during our work with scratch orgs, we need to use a username and password to complete certain tasks. For example:

  1. Installing a package from the Salesforce AppExchange requires a username and password.
  2. Granting access to our development environment to someone who is not a developer, such as a project manager or designer.

To generate a password for our user in the scratch org, we will use the following command:

sfdx force user password generate --target-org myScratchOrgUsername

The output of the command will look like this:

Successfully set the password "yesd_wpwibmP6" for user test-cggfslvemonq@example.com.
You can see the password again by running "<%= config.bin %> org display user -o test-cggfslvemonq@example.com".

To view the user's details, including their password, at a later stage, we will use the following command:

sfdx org display user -o MyScratchOrgUsername

The command's output will display the username and password, along with other details.