获取 unicode 导致 MailChimp oauth2 令牌创建

Getting unicode results in MailChimp oauth2 token creation

我已经使用 https://login.mailchimp.com/oauth2/authorize API. But when I try to create the token using https://login.mailchimp.com/oauth2/token 生成了访问代码,我得到的是这样的 unicode 结果。

(?M?? ?0F?UJ?N?NQ? %`??' "?????nb??f=?&9????i'f??]?~j*$??W??Reg??_T1-???;?oc)

qryStr = {"client_secret":"**********","grant_type":"authorization_code","redirect_uri":"https%3A%2F%2Flocalhost%3A9443%2Fverifymailchimp.sas","client_id":"********","code":"*************"}

HttpURLConnection connection = null;
try
{
    URL reqURL = new URL("https://login.mailchimp.com/oauth2/token");

    connection = (HttpURLConnection) reqURL.openConnection();
    connection.setConnectTimeout(3000); // 3 seconds
    connection.setReadTimeout(5000); // 5 seconds
    connection.setUseCaches(false);
    connection.setRequestProperty("Accept-Charset", "UTF-8"); 
    connection.setRequestProperty("Accept", "application/json");
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); //No I18N
    connection.setRequestProperty("Content-Length", "" + Integer.toString(qryStr.getBytes().length)); //No I18N
    connection.setDoOutput(true);
    OutputStream os = null;
    try
    {
        os = connection.getOutputStream();
        os.write(qryStr.getBytes(CHARSET));
    }
    finally
    {
        try{os.close();}catch(Exception e){}
    }
    int resCode = connection.getResponseCode();
    boolean success = (resCode >= 200 && resCode < 300);


    InputStream is = success ? connection.getInputStream() : connection.getErrorStream();
    if (is == null)
    {
        return null;
    }

    String contentStr = null;
    try
    {
        InputStreamReader reader = new InputStreamReader(is, CHARSET);
        StringBuilder buffer = new StringBuilder();
        char[] bytes = new char[1024];
        int bytesRead;
        while ((bytesRead = reader.read(bytes, 0, bytes.length)) > 0)
        {
            buffer.append(bytes, 0, bytesRead);
        }
        contentStr = buffer.toString();//?M??   ?0F?UJ?N?NQ? %`??' "?????nb??f=?&9????i'f??]?~j*$??W??Reg??_T1-???;?oc
    }
    finally
    {
        try{is.close();}catch(Exception e){}
    }
}

谁能告诉我原因吗?

我找到了这个案例的原因。访问代码的有效期为 30 秒。需要在到期前生成令牌。如果他们传达了正确的错误信息,我们就可以毫无疑惑地解决问题:(