发送令牌并请求SAS URI时出现500内部服务器错误

时间:2016-07-05 19:34:01

标签: java oauth-2.0

我将令牌传递给:

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

我从Access控制服务器获得了access_token,我正在尝试使用它并获取SAS URI但是在标头中传递令牌时我得到的HTTP响应代码为500.(我在生成令牌时错过了范围内的尾随“/”这就是为什么我得到401错误)

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

输出:

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

启用日志:

{{1}}

1 个答案:

答案 0 :(得分:2)

更改以下行

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

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