-
Notifications
You must be signed in to change notification settings - Fork 249
fix: Test transaction may also return 401 when queried in the production environment #315
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
base: master
Are you sure you want to change the base?
Conversation
@BB-5XGames , I think the |
I tried using this interface directly, but it couldn't query the sandbox again in the case of a 401 |
First of all. Per doc, the 401 Unauthorized
It means the jws token you provided is not valid. I think the jws token of your sandbox environment and production environment are different, am I right? If so, I think the better solution to solve it is that try the sandbox environment validation when the error is not nil . The codes like below. func (c *APIClient) Verify(ctx context.Context, transactionId string) (*TransactionInfoResponse, error) {
result, err := c.productionCli.GetTransactionInfo(ctx, transactionId)
if err != nil {
result, err = c.sandboxCli.GetTransactionInfo(ctx, transactionId)
}
return result, err
} Please correct me if anything missing. @BB-5XGames |
…e order in the production environment
I think the JWT used in the test and production environments should be the same, both generated by the code here, right? authToken, err := a.Token.GenerateIfExpired() This is indeed my temporary solution for now func (c *APIClient) Verify(ctx context.Context, transactionId string) (*TransactionInfoResponse, error) {
result, err := c.productionCli.GetTransactionInfo(ctx, transactionId)
if err != nil {
result, err = c.sandboxCli.GetTransactionInfo(ctx, transactionId)
}
return result, err
} |
Yes, the jwt token is same both in test and production environment. However, please make sure the those values of
following this doc https://developer.apple.com/documentation/appstoreserverapi/creating-api-keys-to-authorize-api-requests. Since the return code is 401, it means some of above parameters are not correct. You may double check them. @BB-5XGames |
Yes, I'm sure, the parameters used in the test environment and the real environment are the same |
One more question, does the same parameters works well either on test environment or production environment? I think if the parameters are correct, it is impossible to return 401. |
Right now, my app is not officially launched, so I can't test it in the production environment. However, whether it's testing or production, the TOKEN generated under the same parameters is exactly the same |
Got it. It is so weird that the status code 401 is returned since all those parameters are correct.
|
No description provided.