簡體   English   中英

在發送令牌和請求SAS URI時出現500 Internal Server錯誤

[英]Getting 500 Internal Server error on sending the token and requesting SAS URI

我將令牌傳遞為:

    String access_token = object.get("access_token").toString();
    System.out.println("Access Token -------->" + access_token);
    System.out.println("Decoded Access Token --------> " +URLDecoder.decode(access_token));
    //String basicAuth = "Basic "+ new String(new Base64().encode(access_token.getBytes()));
    CreateSubmissionMetadata(access_token);

public static void CreateSubmissionMetadata (String access_token) throws ClientProtocolException, IOException{

        HttpClient httpClient = HttpClientBuilder.create().build();
        String sysdevEndPoint = "https://devicesigningservice.cloudapp.net/api/signing/devices";
        HttpPost request = new HttpPost(sysdevEndPoint);
        StringEntity params =new StringEntity("{\"TestHarnessType\": \"HLK\",\"OSSelections\": [{\"OS\",\"Windows 7\"},{\"OS\",\"Windows 8\"},{\"OS\",\"Windows 8.1\"},{\"OS\",\"Windows 10\"}],\"ProductName\":\"Test Name\",\"InitialUploadFileSize\": <size>}");
        request.setHeader("Content-Type", "application/json");
        System.out.println("Sending token ---->"+ access_token);
        request.setHeader("Authorization: Bearer ", access_token);
        Log.d("DEBUG", "HEADERS: " + request.getFirstHeader("Authorization: Bearer"));
        request.setEntity(params);
        System.out.println("sending Request-------------------------------------------------------------------------->");
        HttpResponse response = httpClient.execute(request);
        System.out.println("-------------------------------------------------------------------------------------------------------");
        System.out.println(response);
        System.out.println("-------------------------------------------------------------------------------------------------------");
        Header[] headers = response.getAllHeaders();
        for (Header header : headers) {
            System.out.println("Key : " + header.getName() 
            + " ,Value : " + header.getValue());
        }

我從訪問控制服務器獲得了access_token,我試圖使用它並獲取SAS URI,但是在標頭中傳遞令牌時,我得到的HTTP響應代碼為500。(在生成令牌時,我在作用域中未尾隨“ /”,這就是為什么我收到401錯誤)

API文檔: https : //msdn.microsoft.com/zh-cn/library/windows/hardware/dn800660(v=vs.85).aspx

輸出:

HttpResponseProxy{HTTP/1.1 401 Unauthorized [Content-Type: text/html, Server:Microsoft-IIS/8.5, X-Powered-By: ASP.NET, Date: Tue, 05 Jul 2016 19:36:02 GMT,
Content-Length: 1293] ResponseEntityProxy{[Content-Type: text/html,Content-
Length: 1293,Chunked: false]}}
Key : Content-Type ,Value : text/html
Key : Server ,Value : Microsoft-IIS/8.5
Key : X-Powered-By ,Value : ASP.NET
Key : Date ,Value : Tue, 05 Jul 2016 19:36:02 GMT
Key : Content-Length ,Value : 1293

啟用日志:

2016/07/05 16:27:40:237 EDT [DEBUG] RequestAddCookies - CookieSpec selected: default
2016/07/05 16:27:40:237 EDT [DEBUG] RequestAuthCache - Auth cache not set in the context
2016/07/05 16:27:40:238 EDT [DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: {s}->https://devicesigningservice.cloudapp.net:443][total kept alive: 0; route allocated: 0 of 2; total allocated: 0 of 20]
2016/07/05 16:27:40:238 EDT [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 1][route: {s}->https://devicesigningservice.cloudapp.net:443][total kept alive: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2016/07/05 16:27:40:238 EDT [DEBUG] MainClientExec - Opening connection {s}->https://devicesigningservice.cloudapp.net:443
2016/07/05 16:27:40:240 EDT [DEBUG] DefaultHttpClientConnectionOperator - Connecting to devicesigningservice.cloudapp.net/191.246.47.593:843
2016/07/05 16:27:40:240 EDT [DEBUG] SSLConnectionSocketFactory - Connecting socket to devicesigningservice.cloudapp.net/191.246.47.593:843 with timeout 0
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, TLSv1.2]
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Enabled cipher suites:[TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
2016/07/05 16:27:40:256 EDT [DEBUG] SSLConnectionSocketFactory - Starting handshake
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory - Secure session established
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  peer principal: CN=devicesigningservice.cloudapp.net
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  peer alternative names: [devicesigningservice.cloudapp.net]
2016/07/05 16:27:40:517 EDT [DEBUG] SSLConnectionSocketFactory -  issuer principal: CN=Microsoft IT SSL SHA2, OU=Microsoft IT, O=Microsoft Corporation, L=Redmond, ST=Washington, C=US
2016/07/05 16:27:40:518 EDT [DEBUG] DefaultHttpClientConnectionOperator - Connection established 9.82.117.101:65081<->191.246.47.593:843
2016/07/05 16:27:40:518 EDT [DEBUG] MainClientExec - Executing request POST /api/signing/devices HTTP/1.1
2016/07/05 16:27:40:518 EDT [DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 >> POST /api/signing/devices HTTP/1.1
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 >> Content-Type: application/json
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 >> Authorization: Bearer http%3a%2f%2fschemas.microsoft.com%blah%bla
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 >> Content-Length: 181
2016/07/05 16:27:40:518 EDT [DEBUG] headers - http-outgoing-1 >> Host: devicesigningservice.cloudapp.net
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 >> Connection: Keep-Alive
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 >> User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_77)
2016/07/05 16:27:40:519 EDT [DEBUG] headers - http-outgoing-1 >> Accept-Encoding: gzip,deflate
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 << HTTP/1.1 500 Internal Server Error
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 << Cache-Control: no-cache
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 << Pragma: no-cache
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 << Content-Type: application/json; charset=utf-8
2016/07/06 15:14:19:022 EDT [DEBUG] headers - http-outgoing-1 << Expires: -1
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 << Server: Microsoft-IIS/8.5
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 << X-AspNet-Version: 4.0.30319
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 << X-Powered-By: ASP.NET
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 << Date: Wed, 06 Jul 2016 19:14:18 GMT
2016/07/06 15:14:19:023 EDT [DEBUG] headers - http-outgoing-1 << Content-Length: 36
2016/07/06 15:14:19:023 EDT [DEBUG] MainClientExec - Connection can be kept alive indefinitely

更改以下行

request.setHeader("Authorization: Bearer ", access_token);

request.setHeader("Authorization", "Bearer " + access_token);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM