Newer Version Available
Authorize an Org Using a Browser
- Open a terminal (macOS and Linux) or command prompt (Windows).
-
Run the org login web CLI command. We recommend
using the --alias flag to make it easy to refer to
the org later.
1sf org login web --alias my-orgUse the --set-default flag if you want the org to be the default for commands that accept the --target-org flag. If you’re authorizing a Dev Hub org, use the --set-default-dev-hub flag instead. See the org login web command for examples. - In the browser window that opens, sign in to your org with your Salesforce login credentials. Click Allow, which allows Salesforce CLI to access to your org.
- Close the browser window. Your org is now authorized!
1"sfdcLoginUrl" : "https://MyDomainName.my.salesforce.com"This example is for a sandbox.
1"sfdcLoginUrl" : "https://MyDomainName--SandboxName.sandbox.my.salesforce.com"Alternatively, you can use the --instance-url flag of org login web to specify the URL. This value overrides the login URL you specified in the sfdx-project.json file. For example:
1sf org login web --alias my-hub-org --instance-url https://exciting.sandbox.my.salesforce.comThe orgs you authorize for Salesforce CLI are required to have either an external client app (preferred) or a connected app. We provide a default connected app called Salesforce CLI. If you need more security or control, such as setting the refresh token timeout or specifying IP ranges, create your own external client app or connected app (only if you need to create scratch orgs or sandboxes). You can also configure the default connected app to be more secure.