May 19, 2020

Salesforce Refresh Token for an Org in Visual Studio SFDX



Your sandbox got refreshed, what about your code ?

You have an org with manifest (package.xml) SFDX project that you have been working on. Lets say its a partial org or dev org. You have done code modifications, but now your team or SMEs want to refresh that instance. What about your code ? This is not a scratch org !
OR
This was not a planned event and has happened accidentally (someone refreshed the sandbox without your knowledge) in that case you may have received this error upon any CLI interaction..
ERROR running force:org:open:  Error authenticating with the refresh token due to: expired access/refresh token


First things first, always keep checking (committing/pushing) code in a repo. VSCode makes it very simple to use your favorite Version Control System.

Let your sandbox be refreshed and activated. Check whether this is a Auth or Org connection problem by running the command (in VSCode terminal)
sfdx force:org:list --verbose --all
You should see that the org which got refreshed will say at the end 'RefreshTokenAuthError'

Now run the command
sfdx force:auth:web:login --setalias currentOrgAlias --instanceurl https://test.salesforce.com

In the browser window enter the new Org's user/pass and allow CLI permissions

Thats it. you can verify by running the org:list command above that the org now says Connected. You have maintained your org alias by giving the same alias as earlier and the entire code. Just go on Deploying your files and then finally end with a package retrieve.

#InnerCoder

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search