ipatool icon indicating copy to clipboard operation
ipatool copied to clipboard

Reuse credentials within a purchase command to avoid repeated Keychain access

Open DaveMeadAdjust opened this issue 1 week ago • 1 comments

Description

I received multiple Keychain authorization prompts during a single invocation of ipatool purchase --app-id <APP_ID> --format json --non-interactive on macOS.

PR #601 fixed #586 by loading account credentials once before the download retry loop. The standalone purchase command still calls AccountInfo() inside its retry callback, rereading the stored account on each attempt. On macOS, this can trigger repeated Keychain authorization prompts when the user selects Allow rather than Always Allow, because that approval grants only one-time access.

Could the same fix be applied here: call AccountInfo() once before the retry loop and keep the returned account and credentials in memory for the duration of the command? Retry attempts would reuse that account instead of reading Keychain again, updating it after successful reauthentication.

Tested with ipatool 2.8.1 on macOS, Apple Silicon.

DaveMeadAdjust avatar Nov 19 '26 21:11 DaveMeadAdjust

I have a fix for this on a branch, since PRs to this repo are limited to collaborators:

https://github.com/coleleavitt/ipatool/tree/fix/reuse-account-across-retries (commit aee638e, based on current main at 3b02b4c)

It applies the same change #601 made for download: read the account once before the retry loop and keep the refreshed account after reauthentication. Besides purchase, three more commands had the same pattern, so they are fixed too: purchases, list-versions and get-version-metadata.

  • Added a purchase test: the account is read once, and the retry after ErrPasswordTokenExpired uses the refreshed account. It fails on current main and passes with the fix.
  • go vet ./..., go test ./... and go test -race ./cmd/ pass.

Happy to adjust it if you want it in a different shape.

coleleavitt avatar Nov 20 '26 17:11 coleleavitt