Authentication Failure error:
We cannot create LWC, open scratch org,local development or push the changes to the scratch org since the org is expired (min:1 day, max: 30days)and it is not authorized.
I. RESOLVING AUTHENTICATION FAILIURE ERROR
STEP 1
Authorize a dev Hub
Navigation: Click on the org or scratch org
The below SFDX commands and all orgs will be showed in the list
It shows all the connected orgs, scratch org and scratch org that are expired(x) too.
Command palette: SFDX: Authorize a Dev Hub
OUTPUT:
Thus the Dev Hub is authorized.
STEP 2
Set a Default Org
Command palette: SFDX: Authorize an Org
Thus org is authorized.
II. RESOLVING REFRESH TOKEN AUTH ERROR
STEP 3
Pushing Changes to Default Scratch org
Command: SFDX: Push Changes to Default Scratch org
OUTPUT:
ERROR:
PROBLEMS:
It is failed to push changes to default org since the scratch org is expired in 30days here.
STEP 4
Check the orgs list that are connected already and their expiration date
Command: sfdx force:org:list
Delete Expired Scratch org:
Thus the expired scratch orgs are deleted.
III. RE-AUTHORIZE ORG & PUSH CHANGES TO SCRATCH ORG
STEP 5
Authorize dev hub org
Command: sfdx force:auth:web:login –a hlwc05 –d
(Here hlwc05 is the name)
STEP 6
Create a scratch org
Command palatte: SFDX: Create default scratch org
Give the details and set scratch duration to maximum(30days)
STEP 7
Push Changes to scratch org
Command: SFDX: Push Source to Default Scratch Org
OUTPUT:
STEP 8
Open the scratch org or default org
Command: sfdx force:org:open
The default org is opened in browser.
Navigation: Setup -> User Interface -> Lightning App Builder -> New -> LWC Second Scratch Org -> (Fill the details and Lightning Experience)Save
Now you can see all custom Lightning Web components created in VS code. Drag and drop the desired or required Lightning web components.
Source Links:
https://developer.salesforce.com/forums/?id=9062I000000IZK5QAO
https://salesforce.stackexchange.com/questions/255078/remove-expired-scratch-orgs-from-vscode
https://help.salesforce.com/s/articleView?id=000335524&type=1
https://salesforce.stackexchange.com/questions/350610/error-authenticating-with-the-refresh-token-due-to-expired-access-refresh-token?rq=1
https://salesforce.stackexchange.com/questions/342444/sfdx-issue-authorized-dev-sandbox-yet-get-expired-access-refresh-token-when
https://salesforce.stackexchange.com/questions/69161/refresh-token-policy-locked-to-immediatly-expire-token
https://developer.salesforce.com/forums/?id=9062I000000IF92QAG
https://www.greytrix.com/blogs/salesforce/2021/11/24/work-around-for-vs-code-issue-error-authenticating-the-refresh-token-due-to-expired-access-refresh-token/#:~:text=Tricks%20by%20Greytrix-,Work%20around%20for%20VS%20Code%20Issue%3A%20Error%20authenticating%20the%20refresh,to%3A%20expired%20access%2Frefresh%20token&text=You%20would%20not%20find%20any,details%20that%20you%20can%20follow.&text=Secondly%2C%20re%2Dauthorize%20the%20org,refresh%2FDeploy%20metadata%20from%20Salesforce.
https://salesforce.stackexchange.com/questions/255078/remove-expired-scratch-orgs-from-vscode
https://help.salesforce.com/s/articleView?id=000335524&type=1
https://salesforce.stackexchange.com/questions/350610/error-authenticating-with-the-refresh-token-due-to-expired-access-refresh-token?rq=1
https://salesforce.stackexchange.com/questions/342444/sfdx-issue-authorized-dev-sandbox-yet-get-expired-access-refresh-token-when
https://salesforce.stackexchange.com/questions/69161/refresh-token-policy-locked-to-immediatly-expire-token
https://developer.salesforce.com/forums/?id=9062I000000IF92QAG
https://www.greytrix.com/blogs/salesforce/2021/11/24/work-around-for-vs-code-issue-error-authenticating-the-refresh-token-due-to-expired-access-refresh-token/#:~:text=Tricks%20by%20Greytrix-,Work%20around%20for%20VS%20Code%20Issue%3A%20Error%20authenticating%20the%20refresh,to%3A%20expired%20access%2Frefresh%20token&text=You%20would%20not%20find%20any,details%20that%20you%20can%20follow.&text=Secondly%2C%20re%2Dauthorize%20the%20org,refresh%2FDeploy%20metadata%20from%20Salesforce.