so I generated and uploaded self-signed certificate, created an app, selected "Admin approved users are pre-authorized", added username role to approved list and wrote following code (using Ruby and Restforce library):

Restforce.configure do |config|
  config.username = "username"
  config.client_id = "production_client_id"
  config.client_secret = "production_client_secret"
  config.instance_url ="production_instance_url"
  config.jwt_key = "jwt_key"
  config.api_version = '48.0'

Then run:


It works completely fine! I can connect to the API and have full access.

Then I created sandbox, app has been copied to sandbox too. I replaced username, client_id, client_secret, instance_url with sandbox settings. Run "Restforce.new.describe" again and it shows and error:

invalid_grant: user hasn't approved this consumer (400)

What I tried:

1) Change from "Admin approved users are pre-authorized" to "All users may self-authorize", login to test instance with user credentials (permissions are displayed) and confirm.

2) Create new app on sandbox from scratch.

3) Change username from "email@example.com.sandboxname" to "email@example.com" (as on production).

None of the above works for me. The error is the still the same (I read 1st hack helped some people but it doesn't work for me).

  • Along the lines of this issue having been flagged by other users, try a non-JWT flow on your new org.
    – identigral
    May 14 '20 at 17:37
  • ...or wait for N hours and try JWT again.
    – identigral
    May 14 '20 at 19:58
  • Waiting for few days already :(
    – tiktak
    May 14 '20 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.