cli icon indicating copy to clipboard operation
cli copied to clipboard

sf login functions jwt: TypeError: Cannot read properties of undefined (reading 'token')

Open AllanOricil opened this issue 3 years ago • 5 comments

I'm able to login to my org using sf login org jwt -a vdallano -i CLIENT_ID -f ../jwt/server.key -l https://test.salesforce.com -u USERNAME --json, but when I try sf login functions jwt -a vdallano -i CLIENT_ID -f ../jwt/server.key -l https://test.salesforce.com -u USERNAME --json I get the following error TypeError: Cannot read properties of undefined (reading 'token')

image

image

I just changed the word org to functions and hit enter. So what could be the problem?

I tried to update sf to the latest version but it didn't work image

AllanOricil avatar Jun 27 '22 16:06 AllanOricil

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

github-actions[bot] avatar Jun 27 '22 16:06 github-actions[bot]

I am having the same issue on Jenkins slave - Debian: @salesforce/cli/1.34.0 linux-x64 node-v16.15.1 While locally it works fine.

0ptaq0 avatar Jul 07 '22 12:07 0ptaq0

Hi, the same problem here. Could you help?

pgajek2 avatar Jul 07 '22 15:07 pgajek2

It only works with Prod orgs that have functions enabled. You both probably tried to login with a sandbox. As per doc, this seems to be working as designed.

AllanOricil avatar Jul 07 '22 19:07 AllanOricil

The creds were for Production. The issue was that I was trying to log in to org and functions with an API-only user. WORKAROUND: But it requires standard UI login for the first time to accept the Functions access terms. After one-time UI login, I was able to do that with jwt. I guess it is a corner case to be covered by Salesforce.

I have described this issue and some others which I came across during implementing Salesforce Functions in CICD here - https://beyondthecloud.dev/blog/salesforce-functions-in-cicd Hope it helps

0ptaq0 avatar Jul 08 '22 07:07 0ptaq0