SFDX – Error authenticating with auth code due to: grant type not supported

photo of an empty road
Reading Time: 2 minutes

SFDX is the Salesforce command-line interface (CLI) used to deploy and manage your Salesforce applications. Unfortunately, an error can occur when authenticating with an auth code due to the grant type not being supported.

In Salesforce DX, you may experience an error when attempting to authenticate with an authorization code due to the “grant type not supported” error. This error usually occurs when you’re trying to authenticate with wrong instance URL.

For example let’s say you are trying to login to a sandbox

sfdx auth:web:login -a myusername@myorg.sandbox --instanceurl=https://mysandbox-domain.lightning.force.com

And you get this error in console:

ERROR running auth:web:login: Invalid client credentials. Verify the OAuth client secret and ID. Error authenticating with auth code due to: grant type not supported

In your browser you get this

Error authenticating with auth code due to: grant type not supported.

This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.

Just in case please check the following before going to the solution

  • Check that your computer’s clock is accurate: Salesforce uses the OAuth protocol for authentication, which relies on accurate timekeeping. If your computer’s clock is off by more than a few minutes, you may encounter authentication errors.
  • Check your network connection: If your network connection is unstable or slow, you may encounter authentication errors. Make sure you have a stable internet connection.
  • Check your org’s settings: Make sure that your org is configured to allow API access and that your user account has the necessary permissions to access the API.
  • Try logging out and logging back in: Sometimes logging out of SFDX and logging back in can help resolve authentication issues.

The solution

The problem is you are using lightning.force.com domain instead of my.salesforce.com

sfdx auth:web:login -a myusername@myorg.sandbox --instanceurl=https://mysandbox-domain.my.salesforce.com

If none of these steps resolve the issue, you may need to reach out to Salesforce support for further assistance.


About the author

Andrés Canavesi
Andrés Canavesi

Software Engineer with 15+ experience in software development, specialized in Salesforce, Java and Node.js.

Related posts

Leave a Reply

%d bloggers like this: