0

Last week I created a scratch org with no problems. Today I tried creating a new one with:

sfdx auth:web:login to my dev hub account and

sfdx force org create -f config/project-scratch-def.json -a ExampleAlias

but it returned Error (1): Error authenticating with auth code due to: authentication failure. I tried again and got the same error.

However, when I log in the Dev Hub account and check the Active scratch orgs, I see the 2 new ones created, but I can't access them.

sf org list doesn't show them, and everything I try (generating password for the user, opening the scratch org with open -u, etc) returns No authorization information found for ExampleAlias.

How can I access those scratch orgs that have been created but errored on the CLI? Why did the CLI failed in the first place but still created the scratch orgs?

2 Answers 2

1

The solution to my problem (creating and accessing scratch orgs with auth failures post-creation) was to run the scratch org creation commands outside the folder that included my project-scratch-def.json file.

This was because there was already a .sf folder with different settings comparing to my global ones. When I ran the commands in my root dir everything worked as expected.

0

How can I access those scratch orgs that have been created but errored on the CLI?

I don't know of a reasonable way to do this. The nature of the failure is that SFDX/SF CLI was unable to acquire a refresh token for the org during the OAuth exchange, which takes place after the org signup.

Since there's no way to retry that specific part of the process, and the auth code itself is very time-limited, you're probably out of luck on these specific orgs.

What you can do is delete them by removing the corresponding ActiveScratchOrg records in your Dev Hub.

Why did the CLI failed in the first place but still created the scratch orgs?

In my experience, this seems to usually be a platform issue. Specifically, it's a failure in the authentication system. It typically clears up within a day or two, and is most common when you are working with prerelease scratch orgs.

You must log in to answer this question.

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