Metadata Coverage
Resolve Common Authorization Errors
Error: No default dev hub found
Unable to Work After Failed Org Authorization
Error: The consumer key is already taken
CLI Version Information
Limitations for Salesforce DX
Previous PDF Versions
Errors sometimes occur when you run either org login web or org login jwt to log into and authorize an org. Here are some of the more common errors, what they mean, and what you can do to try to fix them.
Before you begin, update to the most recent version of Salesforce CLI and check if you still see the issue. Salesforce releases a new CLI version every week.
If you installed Salesforce CLI using the installers, run this command.
1sf updateIf you installed using npm, run this command.
1npm install --global @salesforce/cliFor each error, we provide this information:
These errors can occur when you run org login web to authorize an org by logging into it using a web browser.
Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: invalid_grant::authentication failure
Error name: AuthCodeExchangeError
What it likely means: You don’t have permission to access the org. The problem can stem from an issue with the connected app, settings, org settings, or with a customization, such as a guest flow that must run before authorization.
Recommended fixes:
doctor command.Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://test.salesforce.com//services/oauth2/token failed, reason: unable to get local issuer certificate
Error name: AuthCodeExchangeError or AuthCodeUsernameRetrievalError
What it likely means: Node.js can’t find the certificate that it uses for HTTPS traffic in the certificate store on the local computer. The problem can be related to a proxy, firewall, or VPN that’s between the client and server. For example, the proxy could be configured for “deep inspection” in which the proxy swaps the SSL certificate with its own certificate to allow it to inspect traffic, and the proxy certificate is causing the error.
Recommended fixes:
NODE_EXTRA_CA_CERTS environment variable to include expected certificates.HTTPS_PROXY and HTTP_PROXY environment variables are set properly.NOT RECOMMENDED:
NODE_TLS_REJECT_UNAUTHORIZED=0, which disables certificate verification for Salesforce CLI requests and allows man-in-the-middle attacks.strict-ssl=false npm configuration setting. This setting allows npm to use HTTP rather than HTTPS and allows unencrypted traffic and man-in-the-middle attacks.Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: unsupported_grant_type::grant type not supported
Error name: AuthCodeExchangeError
What it likely means: The OAuth 2.0 endpoint doesn’t support the grant_type value passed to it. If you’re using the default Salesforce CLI connected app, this error usually means that you’re using the wrong instance URL to log in. If you’re using a different connected app, check to see if it’s configured correctly for the grant types used by the CLI.
Recommended fixes:
https://MyDomainName.my.salesforce.com and not https://MyDomainName.lightning.force.com.https, and not http, for all URLs.Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://test.salesforce.com//services/oauth2/token failed, reason: read ECONNRESET
Error name: AuthCodeExchangeError
What it likely means: Your org reset the connection.
Recommended fixes:
org login web command. This error is sometimes temporary and simply reauthorizing the org fixes it.doctor command.Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://test.salesforce.com//services/oauth2/token failed, reason: connect ETIMEDOUT
Error name: AuthCodeExchangeError
What it likely means: The connection to your org timed out.
Recommended fixes:
org login web command. This error is sometimes temporary and simply reauthorizing the org fixes it.doctor command.Error text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://login.salesforce.com//services/oauth2/token failed, reason: self-signed certificate in certificate chain
Error name: AuthCodeExchangeError or AuthCodeUsernameRetrievalError
What it likely means: During certificate verification, Node.js encountered a certificate that can’t be chained to a root certificate in the local trust store, or the root certificate is not locally trusted. The problem can be related to a proxy, firewall, or VPN that’s between the client and server. For example, the proxy could be configured for “deep inspection” in which the proxy swaps the SSL certificate with its own certificate to allow it to inspect traffic, and the proxy certificate is causing the error.
Recommended fixes:
NODE_EXTRA_CA_CERTS environment variable.HTTPS_PROXY and HTTP_PROXY environment variables are set properly.NOT RECOMMENDED:
NODE_TLS_REJECT_UNAUTHORIZED=0, which disables certificate verification for Salesforce CLI requests and allows man-in-the-middle attacks.strict-ssl=false npm configuration setting. This setting allows npm to use HTTP rather than HTTPS and allows unencrypted traffic and man-in-the-middle attacks.Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: ip restrictedAuthCodeExchangeErrorError text: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: request to https://login.salesforce.com/services/oauth2/token failed, reason: getaddrinfo ENOTFOUND login.salesforce.com
Error name: AuthCodeExchangeError or AuthCodeUsernameRetrievalError
What it likely means: The domain name couldn’t be resolved within the time limit. The error could be caused by an incorrect instance URL, a DNS issue, or a proxy issue.
Recommended fixes:
doctor command.https://MyDomainName.my.salesforce.com and not https://MyDomainName.lightning.force.com.nslookup, to resolve the domain manually from the same computer from which you’re running the org login web command.HTTPS_PROXY and HTTP_PROXY environment variables are set properly.These errors can occur when you run org login jwt to authorize an org by logging into it with the JWT flow.
Error text: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT. Errors encountered: user hasn't approved this consumer
Error name: JwtGrantError
What it likely means: Your connected app settings aren’t configured correctly or a new connected app hasn’t finished replicating.
Recommended fixes:
Use the most recent version of Salesforce CLI and its core plugins. To verify, run the doctor command.
If you recently created the connected app, wait a few minutes for it to finish replicating and then try to authorize again.
Check that your connected app settings are correct, especially if you created your own rather than used the default Salesforce CLI connected app. See Create a Connected App in Your Org. In particular, on the main page where you manage the connected app:
Admin approved users are pre-authorized.Use the correct instance URL when logging in to the org, and make sure that it’s in the correct enhanced My Domain format. You can specify the instance URL either with the --instance-url command flag or the SF_AUDIENCE_URL environment variable, although SF_AUDIENCE_URL isn’t usually needed for production environments. To find your org’s instance URL, log into it, go to the Setup > Company Settings > My Domain page, and see Current My Domain URL. See My Domain Login and Application URL Formats with Enhanced Domains.
Don’t use a Lightning URL for your instance URL. For example, use https://MyDomainName.my.salesforce.com and not https://MyDomainName.lightning.force.com.
Error text: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT. Errors encountered: client identifier invalid
Error name: JwtGrantError
What it likely means: The OAuth client ID (also called consumer key) that you passed to the command’s --client-id flag doesn’t match the one specified in the connected app.
Recommended fixes:
doctor command.org login jwt command.--instance-url command flag or the SF_AUDIENCE_URL environment variable, although SF_AUDIENCE_URL isn’t usually needed for production environments. To find your org’s instance URL, log into it, go to the Setup > Company Settings > My Domain page, and see Current My Domain URL. See My Domain Login and Application URL Formats with Enhanced Domains.https://MyDomainName.my.salesforce.com and not https://MyDomainName.lightning.force.com.We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: ENOENT: no such file or directory, open '/workspace/my-repository/server.key'JwtGrantError--jwt-key-file flag of the org login jwt either doesn’t exist or it’s in a different location. This issue typically occurs in CI (continuous integration) environments where the private JWT key file is accessible for only specific actions.Data Not Available webpage. “The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page”JwtGrantErrorError text: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: Error authenticating with JWT. Errors encountered: audience is invalid [audience=https://login.salesforce.com login=https://test.salesforce.com/]
Error name: JwtGrantError
What it likely means: This error usually occurs with other errors such as user hasn't approved this consumer. This error can also indicate that you used the incorrect instance URL with the command.
Recommended fixes:
doctor command.--instance-url command flag or the SF_AUDIENCE_URL environment variable, although SF_AUDIENCE_URL isn’t usually needed for production environments. To find your org’s instance URL, log into it, go to the Setup > Company Settings > My Domain page, and see Current My Domain URL. See My Domain Login and Application URL Formats with Enhanced Domains.https://MyDomainName.my.salesforce.com and not https://MyDomainName.lightning.force.com.HTTPS_PROXY and HTTP_PROXY environment variables are set properly.See Also