Newer Version Available
Create a Connected App in Your Org
In the task below, the steps marked Required for JWT are required only if you’re creating a connected app to use with the org login jwt command. In this case you also need a file that contains a digital certificate, such as server.crt. The steps are optional if you’re creating a connected app to use with org login web.
-
Contact Salesforce Customer Support to enable the creation of connected apps in your
org.
Creating connected apps is now disabled by default, because connected apps are being deprecated. If you need to create a connected app, Salesforce Customer Support must enable an org perm in your org. This is a one-time process per org. See New connected apps can no longer be created in Spring ‘26.
- Log in to your org.
- From Setup, in the Quick Find box, enter External Client Apps, and then select Settings.
- Turn on Allow creation of connected apps and click Enable.
- Click New Connected App.
- Update the basic information as needed, such as the connected app name and your email address.
- Select Enable OAuth Settings.
-
For the callback URL, enter
http://localhost:1717/OauthRedirect.
If port 1717 (the default) is already in use on your local machine, specify an available one instead. Then update your sfdx-project.json file by setting the oauthLocalPort property to the new port. For example, if you set the callback URL to http://localhost:1919/OauthRedirect:
1"oauthLocalPort" : "1919" - (Required for JWT) Select Use digital signatures.
- (Required for JWT) Click Choose File and upload file that contains your digital certificate, such as server.crt.
-
Add these OAuth scopes:
- Manage user data via APIs (api)
- Manage user data via Web browsers (web)
- Perform requests at any time (refresh_token, offline_access)
- Click Save, then Continue.
-
Click Manage Consumer Details.
If prompted, verify your identity by entering the verification code that was automatically sent to your email address.
- Click Copy next to Consumer Key because you need it later when you run an org login command. Depending on whether you specify that it's required, also copy the Consumer Secret.
- Click Back to Manage Connected Apps.
- Click Manage.
- Click Edit Policies.
-
In the OAuth Policies section, for the Refresh Token Policy field, click
Expire refresh token after: and enter 90 days or less.
Setting a maximum of 90 days for the refresh token expiration is a security best practice. To continue running CLI commands against an org whose refresh tokens have expired, reauthorize it with the org login web or org login jwt command.
-
In the Session Policies section, set Timeout Value to
15 minutes.
Setting a timeout for access tokens is a security best practice. Salesforce CLI automatically handles an expired access token by referring to the refresh token.
- (Required for JWT) In the OAuth Policies section, select Admin approved users are pre-authorized for permitted users, and click OK.
- Click Save.
- (Required for JWT) Click Manage Profiles, select the profiles that are pre-authorized to use this connected app, and click Save. Similarly, click Manage Permission Sets to select the permission sets. Create permission sets if necessary.
1sf org login web --client-id 04580y4051234051 --set-default-dev-hub --alias my-hub-orgIf you specifed in the connected app that the web login flow requires a client (consumer) secret, the command prompts you for it. The command then opens the login page for you to add your org credentials.
See the reference for org login web and org login jwt for more examples.