为什么我从2100测试自动更新订阅的沙箱服务器获得21004作为状态值?

时间:2021-10-07 10:28:22

I'm testing aut-renewable subscription but apple's sandbox server always returns status=21004, which means 'The shared secret you provided does not match the shared secret on file for your account.'. I test with a java server, which does mostly this:

我正在测试自动续订,但apple的沙盒服务器总是返回status = 21004,这意味着'您提供的共享密钥与您帐户的共享密钥不匹配。'。我用java服务器测试,主要是这个:

    String receiptData = "theReceiptDataBytesBase64encoded";
    String sharedSecret = "theSharedSecretAsPureStringProvidedByItunesconnect";


    String jsonData = "{" +
                          "\"receipt-data\" : \"" + receiptData + "\"," +
                          "\"passsword\" : \"" + sharedSecret + "\"" +
                       "}";

    URL url = new URL("https://sandbox.itunes.apple.com/verifyReceipt");
    HttpURLConnection conn = (HttpsURLConnection) url.openConnection();
    conn.setRequestMethod("POST");
    conn.setDoOutput(true);
    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
    wr.write(jsonData);
    wr.flush();

    // Get the response
    BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String line;
    while((line = rd.readLine()) != null)
    {
     System.out.println(line);
    }
    wr.close();
    rd.close();

As I tried to clear up by variable values in code sample above, I didn't encode the shared secret, using it as a plain string. Is this the problem?

当我试图通过上面的代码示例中的变量值清理时,我没有对共享密钥进行编码,将其用作普通字符串。这是问题吗?

1 个解决方案

#1


14  

Those are days that make you feel so great to be a developer ...

这些日子让你觉得成为一名开发人员真是太棒了......

Looking carefully at my question above you'll see that I used the JSON key passsword with 3 friggin' s characters !!! That was the reason for a 5 hour try-and-error experience with several test products and test users and new shared secrets in the app store sandbox.

仔细查看上面的问题,你会发现我使用了带有3个friggin字符的JSON密钥密码!这就是在应用程序商店沙箱中使用多个测试产品和测试用户以及新共享机密的5小时尝试错误体验的原因。

Special thanks to the iTunes team for giving the 'wrong shared secret'-message instead of the 'what the heck is the passsword key'-message.

特别感谢iTunes团队提供“错误的共享秘密”消息,而不是“密码是什么密码”消息。

#1


14  

Those are days that make you feel so great to be a developer ...

这些日子让你觉得成为一名开发人员真是太棒了......

Looking carefully at my question above you'll see that I used the JSON key passsword with 3 friggin' s characters !!! That was the reason for a 5 hour try-and-error experience with several test products and test users and new shared secrets in the app store sandbox.

仔细查看上面的问题,你会发现我使用了带有3个friggin字符的JSON密钥密码!这就是在应用程序商店沙箱中使用多个测试产品和测试用户以及新共享机密的5小时尝试错误体验的原因。

Special thanks to the iTunes team for giving the 'wrong shared secret'-message instead of the 'what the heck is the passsword key'-message.

特别感谢iTunes团队提供“错误的共享秘密”消息,而不是“密码是什么密码”消息。