25

I have a project in Sandbox in Salesforce. Every day when I try to retrieve source from my org I got this error: enter image description here

How to resolve this issue?

The thing is that if I download and create project from scratch then It works but only till the next day. The next day this token automatically expires or something. I am not sure what is the problem, and I start to have this error again. So how to fix this so I don't to have to create a new project every morning?

My sfdx version : sfdx-cli/7.108.0 win32-x64 node-v14.17.1

sfdx update didn't seem to help.

9
  • Is there something that’s modifying some files in .sfdx folder? Also can you add your CLI version (sfdx —version) will give you the version Jul 27, 2021 at 8:50
  • Could you please tell how to add my CLI version and where should I add it?
    – Tema1995
    Jul 27, 2021 at 9:19
  • Execute sfdx --version and add the version to question Jul 27, 2021 at 9:19
  • Added to the question
    – Tema1995
    Jul 27, 2021 at 9:21
  • Run sfdx update so the CLI moves to latest build Jul 27, 2021 at 9:22

5 Answers 5

34

It happened to me every time we refresh our dev org, so you can try to logout your user with the command:

sfdx force:auth:logout -u [email protected]

And then you have to authorize again the org.

As malte wrote in the comment, you have also to reopen VS Code.

3
  • 14
    This helped. But I additionally had to close/reopen the project / VSCode.
    – malte
    Jan 4, 2022 at 8:40
  • Thanks a lot. This helped! To Summarise, 1. Logout using the command: sfdx force:auth:logout -u OrgAlias (eg: sfdx force:auth:logout -u testDev) 2. Close the VSCode. 3. Reopen the VSCode and go to the terminal 4.Re-authorize using the login command: sfdx force:auth:web:login -a OrgAlias (eg: sfdx force:auth:web:login -a testDev) Jul 19 at 14:32
  • Logging out is not necessary. Authorize again and use the same alias. Next, close and re-open VSCode. That's all that's needed.
    – Plinderman
    Aug 15 at 16:24
11

Even I faced the same issue. Solution: I updated the sfdx cli after I logged out and closed the IDE opened again authorized it. It worked

--- Just restarting VS code after authorizing works also (no need to reinstall the cli)

3

None of the solutions above helped me to solve this issue, unfortunately. To solve it I had to :

  1. Use the commander above : sfdx force:auth:logout -u username/alias
  2. Remove/Delete the ".sfdx" folder in the Project
  3. Authorise the Org again

And I was able to retrieve the sources after that.

Hope it'll help

2

It is not necessary to log out of the org using sfdx first. This solution works every time.

  1. Run SFDX:Authorize an Org. Use the same Alias as you did when you initially setup the org.
  2. Restart VsCode

Your deploy/retrieve will now succeed.

0

Whenever I face this issue I execute the following command and it gets resolved:

sfdx force:org:open -u ORG_ALIAS

For ORG_ALIAS either use the org that your are trying to retrieve/deploy metadata from, or your DevHub's alias in case you are doing something where the DevHub is needed (e.g. something with packages).

1
  • I tried this workaround with a sandbox and it did not work. I got the same error response: Error authenticating with the refresh token due to: expired access/refresh token
    – Plinderman
    Aug 15 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .