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?


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)

  • 1
    Thanks for the info! Unfortunately changing this setting doesn't seem to have solved the error. – smohyee May 6 at 15:51

OK, looks like my issue was very basic. I authorized the org, but I didn't set it as my default org. Once I ran

sfdx force:config:set defaultusername=aliasName

I stopped getting authorization errors.

Still not sure why I was getting an expired refresh error because of not setting this, but at least the issue is fixed!

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.