When retrieving Sales and Trends Report via AppStoreConnectAPI, occasionally get a 401 error.

When retrieving Sales and Trends Report via AppStoreConnectAPI, occasionally get a 401 error. The following is the error.

""errors"": [{
		""status"": ""401"",
		""code"": ""NOT_AUTHORIZED"",
		""title"": ""Authentication credentials are missing or invalid."",
		""detail"": ""Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens""
	}]

It appears as if the JWT token was rejected, but the execution after the next day has been completed normally. Also, the validity time for JWT token creation is set to 20 minutes, and the 401 error occurred about 3 minutes after the start of processing, so we do not think it is due to processing delays.

Please allow me to confirm the following.

  1. Are there any conditions under which the JWT token is disabled by Apple?
  2. If so, what can we do about it?

A similar issue has been raised in a Fastlane Issue, and they have responded by getting the JWT back for now. Is this solution correct? https://github.com/fastlane/fastlane/issues/19072 https://github.com/SwiftyMike/fastlane/pull/1/files

Replies

I got the same error, and have no idea to solve it