Deleting an Apex trigger using SFDX CLI can be easily carried out in a few simple steps. Follow these steps to delete an Apex trigger using SFDX CLI:
To check the list of triggers currently present in your project, run the command:
sfdx force:apex:trigger:list
If you have an Apex trigger in Salesforce that you want to delete, you can use the SFDX CLI to do so. Here are the steps to delete an Apex trigger in your Salesforce org using the SFDX CLI.
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.
When running the command that makes the login against our Sandbox org, it redirects to a localhost URL and then it display an error that doesn’t give us so much information
sfdx auth:web:login -a myuser@abc.com --instanceurl=https://xxxxx--xxxxx.my.salesforce.com
The error
Cannot read properties of undefined (reading ‘id’)
This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.
Let say you want to execute this command using Salesforce CLI:
sfdx auth:web:login -a myusername@myorg.sandbox --instanceurl=https://mysandbox-domain.lightning.force.com
This error is shown
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
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.
The issue 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
You are trying to log in through an instance URL (example: sandbox) and you do this.
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.
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
cd some/directory
sfdx auth:web:login -a my@username.dev --instanceurl=https://my-sfdc-instance.my.salesforce.com
sfdx force:project:create -n myProject --manifest
cd myProject
sfdx config:set defaultusername=my@username.dev
# Modify the package xml to retieve whatever we want
sfdx force:source:retrieve -x manifest/package.xml
# or retrieve this way
sfdx force:source:retrieve -m "ApexClass:MyApexClass"