I have been trying to set up Circle ci with GitHub for continuous integration and continuous delivery(CI/CD) in salesforce dx project using this refernce link, but I'm facing an issue with the connected app for JWT authorization in Circle Ci using this SFDX command.

sfdx force:auth:jwt:grant --clientid $HUB_CONSUMER_KEY  --jwtkeyfile assets/server.key --username $HUB_SFDC_USER  --setdefaultdevhubusername -a hub

Which works fine in the local system, as per reference link I have configured the environment variable and connected app with the right setup

Connected App Jwt Configuration but still facing this error.

This org appears to have a problem with its OAuth configuration. Reason: invalid_grant - user hasn't approved this consumer

I have googled about this error and found that I have to authorize our connected app once to refresh token then it will work fine but still get no success. Here are my some findings

Salesforce JWT User Hasn't Approved This Consumer (Again)

{ "error" : "invalid_grant", "error_description" : "user hasn't approved this consumer"}

Any help with this will save my time.

1 Answer 1


Your integration user needs to be pre-authorized on the Connected App via a Profile or Permission Set.

You can find specific instructions in the Salesforce DX Developer Guide. What you're missing is steps 13-15, where you add specific Profiles and Permission Sets to your Connected App's settings to preauthorize them.

Make sure to only preauthorize Profiles and Permission Sets you actually want to use, as no additional authorization on a per-user basis is required. This can produce a security hole if not configured correctly.

  • I have already set "Admin approved users are pre-authorized" for the permitted user in OAuth Policies section and for profile and permission I'm authorizing as a system administrator that is already configured in the respective section.
    – kunal
    Jul 8, 2019 at 13:06
  • @kunal The error suggests that the user you're authenticating with in CI is not the right one or is not on the appropriate profile. I'd suggest re-checking the CircleCI environment variables and the configuration of that user, since it's working for you locally.
    – David Reed
    Jul 8, 2019 at 13:20
  • yeah, I have rechecked my environment variable and configured the right username but still facing the same problem. I can't understand why it's not working here, as previously I have also integrated bitbucket pipeline with the sfdx project with the same configuration for JWT authorization which worked correctly.
    – kunal
    Jul 8, 2019 at 13:35
  • I rechecked reference link again and found that In config.yml they are using HUB_SFDC_USER, but in environment variable section, they created with another name HUB_SFDX_USER. I changed my yml now it's working fine
    – kunal
    Jul 9, 2019 at 5:04
  • 1
    @Bahman.A I'd suggest posting a new question.
    – David Reed
    Mar 23, 2021 at 16:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .