[SalesForce] SFDX : invalid_grant message: user hasn’t approved this consumer

I am trying build bitbucket pipelines with SFDX and got stuck in the first stage.

I have followed this blog and created serverykey and certificate files.

http://www.wadewegner.com/2018/01/jwt-oauth-with-scratch-orgs/

And created Connected App and added certificate:

enter image description here

Added permissions to the connected app:
enter image description here

enter image description here

And also configured the Environment variables in Bitbucket:
enter image description here

Added serverkey to bitbycket:
enter image description here

And here is my yml script:

# CI process for SFDX
image: illbilly/sfdx #image with sfdx installed
pipelines:
  default: #this will run for all branches unless specificed otherwise
    - step:
        name: Auth. with DevHub
        script:
                - sfdx force:auth:jwt:grant -i $CLIENT_ID -f jwt/server.key -u $DEVHUB_USERNAME --setdefaultdevhubusername --setalias DevHub
                - sfdx force:org:list
    - step:
        name: Create Scratch Org.
        script:
                - sfdx force:org:list
                - sfdx force:org:create -f environments/scratchorg1-scratch-def.json -v DevHub -a bitbucket_build_$BITBUCKET_BUILD_NUMBER

When I run the build: I am getting this below error, inspite of having the profile access to the connected app. what am I missing:

enter image description here

ERROR:

An error occurred authorizing this org. name: invalid_grant message: user hasn't approved this consumer

Best Answer

My bad. It was too silly mistake what I have done. The username of the org is wrong in environment variables in bitbucket.

I got another issue, let me see how can fix it.l

Related Topic