Can I connect to a sandbox using JWT Flow and Prod connect app?

I’m trying to connect to a sandbox using the sfdx cli and the JWT flow through force:auth:jwt:grant. According to this Salesforce DX doc, we can use the same connected app information from Production to connect to our Scratch Org.

Is it something that should work for sandbox too ? I’m getting a “Failed: Not approved” error.

Connected app in sandbox comes from the refresh but has a different consumer key. The Permission set is set correctly on my user.

Is there a way to connect to a recently refreshed sandbox using the JWT flow (without manually changing something like the consumer key) ?


You can use the Connected App from your production org, but to avoid the user hasn't approved this consumer error, I’ve found that you need to authenticate using the password and the Connected App’s Client Id first. Then you’ll be able to authenticate with JWT using the key.

Source : Link , Question Author : Fabien Taillon , Answer Author : xn.

Leave a Comment