I connected to Production Org with JWT through connected app without any difficulty. However, by applying the same procedure, I could not connect to Sandbox using JWT.
Here is my command:
sfdx force:auth:jwt:grant --clientid consumerKeyOfConnectedAppInSandbox --jwtkeyfile myKey --username myUsername --setalias aliasName --instanceurl https://test.salesforce.com
And the error message goes:
ERROR running force:auth:jwt:grant: We encountered a JSON web token error, which is likely not an issue with Salesforce CLI. Here’s the error: user hasn't approved this consumer
I have granted my profile "System Admin" to the connected app. I even created a permission set with my username inside. But the same error message still appears.