I just spun up a new sandbox (couple of hours old) and I am trying to setup a CI/CD process using BitBucket Pipelines and sfdx. When I run the force:auth:jwt:grant command with hardcoded values (i.e. client id, jwtkeyfile) and I am getting intermittent successes and failures. The error message I am getting is "
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". Again the sandbox is relatively new and this error message happens 50-60% of the time. Any ideas?
Asked
Active
Viewed 1,668 times
0
Bryan Anderson
- 2,396
- 14
- 17
-
2Does this answer your question? Oauth throws "invalid_grant: user hasn't approved this consumer" randomly for Community Login profile – identigral Feb 12 '20 at 00:03
-
2I've run into that error when the connected app used in the JWT flow hasn't been installed in the target org, but I'd think that'd give you a 100% fail rate. Is your connected app in your target org(s)? Is your connected app set to "users may self-authorize" or "selected profiles are pre-authorized"? Is your CI/CD pipeline using multiple users, or just a single user (when trying to auth, that is)? – Derek F Feb 12 '20 at 00:06
-
The endpoint URL is usually the issue. Same root cause, different symptoms: https://salesforce.stackexchange.com/questions/278367/error-running-forceauthjwtgrant-destination-url-not-reset-the-url-returned – identigral Feb 12 '20 at 00:08
-
@derekf it is one user only and the Connected app is in the target org. Identigral it's interesting that issue sounds like mine, but no communities in my org. – Bryan Anderson Feb 12 '20 at 00:26
-
I am wondering if it has to do with the "newness" of the sandbox – Bryan Anderson Feb 12 '20 at 00:28
1 Answers
0
So after 12 hours of sleeping, it seems as though the issue was DNS / Sandbox propagation. After waiting 12 hours, the authentication requests succeed every time now. Once again this is a very common issue with new Sandboxes and Authentication I have seen many times.
Bryan Anderson
- 2,396
- 14
- 17