XcodesOrg / xcodes

The best command-line tool to install and switch between multiple versions of Xcode.
MIT License
3.68k stars 127 forks source link

Login with SMS 2FA code fails with "The data couldn’t be read because it is missing" #96

Closed bonkey closed 3 years ago

bonkey commented 4 years ago

Can't get the list of Xcodes from Apple when login with 2FA account.

$ xcodes list
Apple ID: foo@bar.com
Apple ID Password:
Enter the code:
000000
The data couldn’t be read because it is missing.

Second try is the same:

$ xcodes list
Enter the code:
000001
The data couldn’t be read because it is missing.
interstateone commented 4 years ago

Thanks for filing this @bonkey, and sorry that xcodes isn't working for you.

In addition to fixing this, I think the "Enter the code:" message and this error message could both be improved.

I'll have to see if I can reproduce this particular failure. Is it correct that this occurred the first time you were using xcodes, and you haven't successfully used it before?


Note to self: this sounds similar to #52, but with a worse error message in this case.

bonkey commented 4 years ago

Thanks for filing this @bonkey, and sorry that xcodes isn't working for you.

My pleasure I could help somehow :)

In addition to fixing this, I think the "Enter the code:" message and this error message could both be improved.

Yes, could be better. For me, however, it wasn't an issue as I'm used to 2FA, so I knew instantly what kind of code it was.

Is it correct that this occurred the first time you were using xcodes, and you haven't successfully used it before?

Yes, correct. First time ever and no earlier sukcesem.

paulthorsteinson commented 4 years ago

@interstateone I am also getting this today

paulthorsteinson commented 4 years ago

@interstateone must have been an issue with the apple site, working for me today

bonkey commented 4 years ago

@interstateone must have been an issue with the apple site, working for me today

For me still the "second" case holds, alas:

$ xcodes list
Enter the code:
123123
The data couldn’t be read because it is missing.
aerickson14 commented 4 years ago

I encountered this error as well today. Having 2fa set up on my account I was prompted to "Enter the code:". I received the code via text message and entered it when prompted resulting in "The data couldn't be read because it isn't in the correct format."

I am on VPN as well that is known to sometimes block apple sites and paths intermittently, but did a test to temporarily disable VPN and reissue the xcodes list command resulting in the same error.

What I did observe is that the codes being sent by text message seemed significantly delayed (5 minutes or so). Almost to the point where I may have been entering in an expired code and the "new" auth code still hadn't been delivered to my phone.

I was able to get around this issue by switching my developer account using export XCODES_USERNAME=another.account@example.com after which I was prompted to login with that account. The difference between these two accounts were that the second account delivered the 2fa code directly to my Mac instantaneously. Using that code I was able to get a successful response from xcodes list and subsequently start the install of the Xcode version I was looking for. Worth noting that I was still on VPN throughout this whole process.

interstateone commented 4 years ago

The difference between these two accounts were that the second account delivered the 2fa code directly to my Mac instantaneously.

If I recall correctly this is an important distinction, and I might have only implemented the latter path when I first started xcodes because it's the one I needed. I, uh, never revisited that 😬. fastlane handles both of these cases, so we have something to reference.

This might explain at least the auth-related errors. It probably doesn't explain the intermittent ones, but it's hard to say that certainly because "The data couldn’t be read because it isn’t in the correct format." is such a bad error message...

bonkey commented 3 years ago

@interstateone This goes along my case as I'm using SMS on that account.

interstateone commented 3 years ago

Thanks for confirming that @bonkey! I'm going to use this issue to track support for accounts with SMS 2FA, and I've started work on it.

paulthorsteinson commented 3 years ago

@interstateone same issue for me again today doing xcodes update right after inputting MFA code

interstateone commented 3 years ago

@paulthorsteinson Do you use SMS or the device-based 2FA codes (or both, I guess)?

paulthorsteinson commented 3 years ago

Using SMS

interstateone commented 3 years ago

👍 Okay, that fits with this comment then. I'm not sure it's 100% baked yet, but if you feel like testing out a fix, I've implemented the SMS flow in this PR.

interstateone commented 3 years ago

@bonkey @paulthorsteinson This was auto-closed by merging #107, but try out the newly released 0.12.0 version and let me know if SMS 2FA works any better for you now.

bonkey commented 3 years ago

@interstateone Worked like a charm. Thank you!