亚马逊云盘 rest 遇到 https 400 错误代码 api

https 400 error code encountered for amazon cloud drive rest api

我提出这个要求

https://www.amazon.com/ap/oa?client_id=amzn1.application-oa2-   
clientxxxxxxxxxxxxxxxxxxxxxxxxx&scope=clouddrive%3Aread%20clouddrive%3
Awrite&response_type=code&redirect_uri=https://roscasend.go.ro:8443/

并且我已成功重定向到此页面

 https://roscasend.go.ro:8443/?code=cccccccoooooodeeeeeee&scope=
 clouddrive%3Aread+clouddrive%3Awrite

但是当根据以下请求更新字段时

 POST https://api.amazon.com/auth/o2/token HTTP/1.1
 Host: api.amazon.com
 Content-Type: application/x-www-form-urlencoded
 Cache-Control: no-cache
//those are the post's request arguments
grant_type=authorization_code&code=cccccccoooooodeeeeeee
&client_id=amzn1.application-oa2-clientxxxxxxxxxxxxxxxxxxxxxxxxx&
client_secret=secret______________________&redirect_uri=   
http%3A%2F%2Froscasend.go.ro%3A8443

我的凭据遇到了 400 错误。

关于如何更新上述请求以便工作,你能给我任何解决方案吗?

请注意,第一个请求是在浏览器中,第二个请求是通过 java。

BasicCookieStore cookieStore = new BasicCookieStore();
        CloseableHttpClient httpclient = HttpClients.custom()
                .setDefaultCookieStore(cookieStore)
                .build();


        HttpUriRequest login = null;
        try {
            login = RequestBuilder.post()
                    .setUri(new URI("https://api.amazon.com/auth/o2/token"))
                    .addParameter("grant_type", "authorization_code")
                    .addParameter("code", "cccccccoooooodeeeeeee")
                     .addParameter("client_id", "amzn1.application-oa2-clientxxxxxxxxxxxxxxxxxxxxxxxxx")
                     .addParameter("client_secret", "secret______________________")
                     .addParameter("redirect_uri", "https://roscasend.go.ro:8443/")
                    .build();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        //login.addHeader("Content-Type", "application/x-www-form-urlencoded");
        //login.addHeader("Host", "api.amazon.com");
        login.addHeader("Cache-Control", "no-cache");

        CloseableHttpResponse response2 = null;
        try {
            response2 = httpclient.execute(login);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        try {
            HttpEntity entity = response2.getEntity();

            System.out.println("Login form get: " + response2.getStatusLine());

            InputStream in =   entity.getContent();
            InputStreamReader is = new InputStreamReader(in);
            StringBuilder sb=new StringBuilder();
            BufferedReader br = new BufferedReader(is);
            String read = br.readLine();

            while(read != null) {
                //System.out.println(read);
                sb.append(read);
                read =br.readLine();

            }

            EntityUtils.consume(entity);

            System.out.println(sb.toString());

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            try {
                response2.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            try {
                httpclient.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }