0

I have set up a Custom app on an enterprise-edition org to deploy source to, and am able to authorize using force:auth:jwt:grant on my dev machine (Windows 10), but the build machine (Windows Server 2016 10.0.14393) consistently connects to a different organization than the one the connected app is defined in.

As a result, the deploy fails.

The server had connected to another org which has since been deleted. A new organization was created with the same name and user login, and the certificate loaded into a connected app on that organization. I have confirmed the server is using the new consumer key for the connected app.

Any suggestions on how to get around this?

Commands on server:

sfdx force:auth:jwt:grant -i [certificate] -f server.key -u enterprise@voicestorm.biz -a enterprise

response:

Successfully authorized enterprise@voicestorm.biz with org ID 00D5A00000080jQUAQ

sfdx force:source:deploy -p .\force-app\main\ -w 10 -u enterprise

response:

ERROR running force:source:deploy:  This org appears to have a problem with its OAuth configuration. Reason: invalid_grant - user hasn't approved this consumer
username: enterprise@voicestorm.biz, 
clientId: [different client id], 
loginUrl: https://login.salesforce.com, 
privateKey: server.key 

Try this: 
Verify the OAuth configuration for this org. For JWT:
Ensure the private key is correct and the cert associated with the connected app has not expired.
Ensure the following OAuth scopes are configured [api, refresh_token, offline_access].
Ensure the username is assigned to a profile or perm set associated with the connected app.
Ensure the connected app is configured to pre-authorize admins.

Commands on dev machine:

sfdx force:auth:jwt:grant -i [certificate] -f server.key -u enterprise@voicestorm.biz -a enterprise

response:

Successfully authorized enterprise@voicestorm.biz with org ID 00D6g000001Y9z2EAC

sfdx force:source:deploy -p .\force-app\main\ -w 10 -u enterprise

response:

=== Deployed Source...

5
  • 1
    The username, not the connected app, dictates what org you attempt to connect to. It sounds like your pipeline is configured with an incorrect username somewhere. – David Reed Dec 4 '19 at 20:01
  • I have copied the command line used in the server to my dev machine (including the username), and the dev machine connects to the correct org, but the server does not. – debdysi Dec 4 '19 at 20:49
  • Please edit your question to provide the commands involved and as much other relevant information as you can. – David Reed Dec 4 '19 at 21:07
  • So you did verify 00D5A00000080jQUAQ is not the current ORG Id, correct? – Glen De Marcos Dec 5 '19 at 1:17
  • Correct. 00D6g000001Y9z2EAC is the correct Org Id. – debdysi Dec 6 '19 at 19:22
0

I would suggest to try running the "force:auth:logout" command before the login command.

In your case verify username, consumer key are all setup correctly in the pipeline.

0

I wound up creating an additional user in the organization with a slightly different name so Salesforce wouldn't tie the user to the old organization. That solved the problem.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.