web Commands

Authorize an org using a web browser.

auth:web:login

Authorize an org using the web login flow.

As of April 20, 2023, we no longer maintain this section of the command reference. Refer to the reference information about the sf-style commands instead, which we update regularly. We keep this reference information about the sfdx-style commands as-is for historical reference only.

Don't worry, this command and its flags continue to work the same as before, and any scripts that use the command won’t break. However, we recommend that you start using the equivalent sf-style org login web command instead. Here’s how the flags changed between the old and new commands; if a flag isn't listed, the old and new names are the same:

  • Removed flag: --loglevel. Use the SF_LOG_LEVEL environment variable instead.
  • Changed flag name: Old name --clientid. New name: --client-id.
  • Changed flag name: Old name --setdefaultdevhubusername. New name: --set-default-dev-hub.
  • Changed flag name: Old name --setalias. New name: --alias.
  • Changed flag name: Old name --instanceurl. New name: --instance-url.
  • Changed flag name: Old name --setdefaultusername. New name: --set-default.

For background information about this change, read this blog post, which describes how we've updated many of the existing sfdx commands to use the improvements we made in sf. We improved this particular command on March 2, 2023.

Warning

Help for auth:web:login

If you specify an --instanceurl value, this value overrides the sfdcLoginUrl value in your sfdx-project.json file. To specify a My Domain URL, use the format MyDomainName.my.salesforce.com (not MyDomainName.lightning.force.com). To log in to a sandbox, set --instanceurl to https://MyDomainName--SandboxName.sandbox.my.salesforce.com.

To open in a specific browser, use the --browser parameter. Supported browsers are "chrome", "edge", and "firefox". If you don't specify --browser, the org opens in your default browser.

Examples for auth:web:login

1sfdx auth:web:login -a TestOrg1
1sfdx auth:web:login -i <OAuth client id>
1sfdx auth:web:login -r https://MyDomainName--SandboxName.sandbox.my.salesforce.com
1sfdx auth:web:login -a TestOrg1 -b firefox

Command Syntax

sfdx auth:web:login
[--json]
[--loglevel LOGLEVEL]
[-b BROWSER]
[-i CLIENTID]
[-r INSTANCEURL]
[-d]
[-s]
[-a SETALIAS]

Parameters

--json
Optional

Format output as JSON.

Type: boolean
--loglevel LOGLEVEL
Optional

The logging level for this command invocation. Logs are stored in $HOME/.sf/sf.log.

Type: enum
Permissible values are: trace, debug, info, warn, error, fatal, TRACE, DEBUG, INFO, WARN, ERROR, FATAL
Default value: warn
-b | --browser BROWSER
Optional

Browser where the org opens.

Type: enum
Permissible values are: chrome, edge, firefox
-i | --clientid CLIENTID
Optional

OAuth client ID (sometimes called the consumer key).

Type: string
-r | --instanceurl INSTANCEURL
Optional

The login URL of the instance the org lives on.

Type: url
-d | --setdefaultdevhubusername
Optional

Set the authenticated org as the default dev hub org for scratch org creation.

Type: boolean
-s | --setdefaultusername
Optional

Set the authenticated org as the default username that all commands run against.

Type: boolean
-a | --setalias SETALIAS
Optional

Set an alias for the authenticated org.

Type: string

Aliases for auth:web:login

1force:auth:web:login