Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"download dev": two-factor authentication error 412 when many trusted phones #79

Closed
homebinary opened this issue Feb 14, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@homebinary
Copy link

homebinary commented Feb 14, 2022

When many (for me it is 6 phones) trusted phones used in Apple ID and used phone with non first ID download dev finished with 412 error:

⨯ failed to verify code: response received 412

This caused with next code where ID=1 is hardcoded internal/download/dev_portal.go

func (app *App) verifyCode(codeType, code string) error {
	buf := new(bytes.Buffer)
	if codeType == "phone" {
		json.NewEncoder(buf).Encode(&phone{
			Number: phoneNumber{
				ID: 1,
			},
			Mode: "sms",
			SecurityCode: scode{
				Code: code,
			},
		})
...
@homebinary homebinary changed the title download dev two-factor authenticating error 412 when many trusted phones "download dev": two-factor authentication error 412 when many trusted phones Feb 14, 2022
@blacktop
Copy link
Owner

412 PRECONDITION FAILED
One or more conditions given in the request header fields evaluated to false when tested on the server.

Can you describe more about what you were doing when you saw the error?

I don't understand:

When many (for me it is 6 phones) trusted phones used in Apple ID and used phone with non first ID download dev

@homebinary
Copy link
Author

homebinary commented Feb 14, 2022

Apple ID can have several trusted phones. My Apple ID have 6 phones. When I choose last one (with ID=6), Apple server (https://idmsa.apple.com/appleauth/auth/verify/phone/securitycode) return 412 code.
If I change code to:

json.NewEncoder(buf).Encode(&phone{
			Number: phoneNumber{
				ID: 6,
			},

(hard code ID=6)
and recompile ipsw, error disappear for this trusted phone.

@blacktop
Copy link
Owner

Aww yes, I see what you mean! I need to support allowing the user to pick 1 out of many iDevices to choose from when entering the 2factor code!

@blacktop blacktop added the bug Something isn't working label Feb 14, 2022
@homebinary
Copy link
Author

It is already done in UI! But not working in backend... There is phone choose, but ID in POST method always equals 1.

@blacktop
Copy link
Owner

This should be fixed in the latest release. Thank you for reporting! I vaguely remember when I first wrote this cmd that I was testing it so much that Apple flat out refused to send me ANY more SMS codes to my device and would ONLY do "trusted-device" push notifications. I also have only 1 device 😞 so I didn't notice this bug. Thank you! 👍

@blacktop
Copy link
Owner

feel free to close the issue if the fix is good

@homebinary
Copy link
Author

works great. good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants