ipatool icon indicating copy to clipboard operation
ipatool copied to clipboard

appstore: Fix/invalid auth code

Open coleleavitt opened this issue 3 months ago • 3 comments

This pull request improves error handling for App Store login, specifically around two-factor authentication (2FA) codes. It introduces a new error for invalid or expired 2FA codes, enhances the logic for parsing login responses, and adds comprehensive test coverage for these scenarios.

Error handling improvements:

  • Added a new error ErrInvalidAuthCode to represent invalid or expired 2FA codes in appstore_login.go.
  • Updated the login response parser to return ErrInvalidAuthCode for various failure types and customer messages related to invalid 2FA codes.
  • Included the FailureTypeInvalidAuthCode constant ("5005") to identify invalid auth code errors from the API.
  • Improved generic error reporting by including the failure type in error messages for easier debugging.

Test coverage enhancements:

  • Added new tests to ensure that invalid or expired 2FA codes return the correct error, and that error messages include the failure type when appropriate. [1] [2] [3]

fixing #392 and #387

need to reference @pradeepvizz for suggesting one request a 2FA code on the website and then utilizing that through the auth-code parameter.

coleleavitt avatar Sep 09 '25 21:09 coleleavitt

hi, could you tell how can I use this tool? I try to build binary exe file and run

✦3 ❯ ./ipatool auth login -e [email protected] -p xxxxxxxxx  --verbose                 
[4] 18822
zsh: command not found: 8c

ipatool on  fix/invalid-auth-code [?] via 🐹 v1.24.1 
✦4 ❯ 8:05AM INF enter 2FA code:

[4]  + suspended (tty input)  ./ipatool auth login -e [email protected] -p xxxxxxxxx

but the process was already terminated before I had a chance to enter the 2FA code.

AkimioJR avatar Sep 14 '25 00:09 AkimioJR

hi, could you tell how can I use this tool? I try to build binary exe file and run

✦3 ❯ ./ipatool auth login -e [email protected] -p xxxxxxxxx  --verbose                 
[4] 18822
zsh: command not found: 8c

ipatool on  fix/invalid-auth-code [?] via 🐹 v1.24.1 
✦4 ❯ 8:05AM INF enter 2FA code:

[4]  + suspended (tty input)  ./ipatool auth login -e [email protected] -p xxxxxxxxx

but the process was already terminated before I had a chance to enter the 2FA code.

you need to escape like wrap your email in double quotes it looks like "[email protected]" and also you need to request a 2fa code from the official apple site when you login and use that 2fa code when you're trying to login

coleleavitt avatar Sep 18 '25 16:09 coleleavitt

hi, could you tell how can I use this tool? I try to build binary exe file and run

✦3 ❯ ./ipatool auth login -e [email protected] -p xxxxxxxxx  --verbose                 
[4] 18822
zsh: command not found: 8c

ipatool on  fix/invalid-auth-code [?] via 🐹 v1.24.1 
✦4 ❯ 8:05AM INF enter 2FA code:

[4]  + suspended (tty input)  ./ipatool auth login -e [email protected] -p xxxxxxxxx

but the process was already terminated before I had a chance to enter the 2FA code.

you need to escape like wrap your email in double quotes it looks like "[email protected]" and also you need to request a 2fa code from the official apple site when you login and use that 2fa code when you're trying to login

thanks for your help, I login successfully

AkimioJR avatar Sep 19 '25 07:09 AkimioJR