2016-07-05 9 views
1

I Token als ich vorbei:Erste 500 Internal Server-Fehler auf den Token Senden und Anfordern 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()); 
     } 

ich von Access Control Server access_token bekam, und ich versuche, das zu nutzen und SAS URI erhalten, aber beim Durchgang das Token in Header ich erhalte HTTP-Antwortcode als 500. (I den abschließenden "/" im Rahmen verpasst, während Token, das ist zu erzeugen, warum ich 401-Fehler bekommen)

API Dokument: https://msdn.microsoft.com/en-us/library/windows/hardware/dn800660(v=vs.85).aspx

Ausgabe:

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 

Aktivieren Protokoll:

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 

Antwort

2

ändern folgende Zeile

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

zu

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

habe ich die oben erwähnte Änderung noch bin ich den gleichen Fehler. – MikasaAckerman

+1

Das war der erste Fehler :) poste deinen Code nach der Änderung und der Ausgabe, die du bekommst. – 11thdimension

+0

ja, stimmt das. Die Ausgabe bleibt immer gleich. Ich habe den Teil hinzugefügt, wo ich Token an die Methode übergebe. – MikasaAckerman