I recently refreshed my developer sandbox.
In VS Code, I ran
sfdx force:auth:web:login --setalias aliasName --instanceurl https://test.salesforce.com --setdefaultusername
It opened the OAuth window and I logged in. I noted that I wasn't prompted to grant access permission to SFDX cli, nor do I see such an app in the sandbox's app manager.
Back in VS code, if I run
sfdx force:org:display --targetusername aliasName
I get an org description of my sandbox the a Connected Status of 'Connected'. If I run sfdx force:org:open
, my sandbox opens in browser.
When I open the context menu on files in my local repo I see options for SFDX: Deploy Source to Org
and SFDX: Retrieve Source from Org
..
And yet, when I attempt either one of these, I get the following error:
'Error authenticating with the refresh token due to: expired access/refresh token'
If I had to guess this has to do with me not having a proper connected app set up in my sandbox, but I'm not sure what step to take other than authorizing the org through SFDX. What am I missing?
Best Answer
This is a bug/feature of a recent change to the Salesforce CLI to use REST by default (whereas it previously used SOAP to deploy/retrieve).
You can avoid this issue for now while they (the sf cli team) work out the kinks by disabling restDeploy
sfdx config:set restDeploy=false
(add the -g flag to the command if you want to make that global).You can achieve the same thing by adding
"restDeploy": "false"
into the sfdx-config.json for an sfdx project (in the .sfdx directory)