I run the command from my build job within Teamcity CI:

sfdx force:auth:jwt:grant --clientid '%SFDX_HUB_CONSUMER_KEY%' --jwtkeyfile config/server.key --username %SFDX_HUB_USERNAME% --setalias hub1 --loglevel trace

But i get the error:

ERROR running force:auth:jwt:grant:  This org appears to have a problem with its OAuth configuration. Reason: invalid_grant - expired authorization code 
username: abc@wyz.com, 
clientId: xxxxxxx, 
loginUrl: https://login.salesforce.com, 
privateKey: config/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.

I already verified the consumer key from the connected app and i also checked the key, which looks ok. Because this all works from my local machine.

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.