apple / app-store-server-library-java

MIT License
169 stars 38 forks source link

AppStoreServerAPIClient is connecting to Production when the environment is Xcode or LocalTesting #84

Closed at9pm closed 7 months ago

at9pm commented 7 months ago

In the constructor of AppStoreServerAPIClient. If the environment is Xcode or LocalTesting, it is also connected to production, probably it is the reason for me to get an 401 HTTP response. this.urlBase = HttpUrl.parse(environment.equals(Environment.SANDBOX) ? SANDBOX_URL : PRODUCTION_URL);

Btw, what is the difference between Xcode and LocalTesting?

alexanderjordanbaker commented 7 months ago

Xcode environment makes more sense as an environment to the SignedDataVerifier to verify receipts generated in Xcode. LOCAL_TESTING is for unit tests to use an environment that does not correspond to a real environment

at9pm commented 7 months ago

Thanks Alex, that helps. In other words, the Xcode environment is only intended for SignedDataVerifier to decode messages, but not for API server client to request app store server, right? If it is the case, perhaps it should throw exception at the time of constructing the API client if the environment is neither sandbox nor production. I am new to App Store API, it actually spent me quite some time to figure out if the environment is Xcode, some methods cannot be used. (such as get transaction info by transaction id)

alexanderjordanbaker commented 7 months ago

This has been improved in #89 to throw an exception when Xcode is passed as an argument to the AppStoreServerAPIClient. LOCAL_TESTING is kept but added a comment to make it a little clearer that is used for unit testing only.