Yahoo Messenger に接続する Java アプリケーションを作成しています。Yahoo の Github にある Java コードを再利用していますが、次のエラーが発生します。
java.io.IOException: サーバーが HTTP 応答コードを返しました: URL の 401
完全なログは次のとおりです。
2015-10-26 14:40:11.652 DEBUG [main] (YahooMessengerLoginManager:84) Requesting PART Token
2015-10-26 14:40:11.655 DEBUG [main] (HttpUtils:32) HTTP GET: https://login.yahoo.com/WSLogin/V1/get_auth_token?login=USER&passwd=PW&oauth_consumer_key=KEY
2015-10-26 14:40:12.213 DEBUG [main] (HttpUtils:59) HTTP Response Code: 200; HTTP Response: RequestToken=T9pkITxu3AbVKLSwxx_WtWYVhE5eRa_QaIjDJQ0Tu_0zJ2x8I3PwtRLdckayPbSDdcKyteHgzXocgL66790kvZ.rJ1Pt8hIYkaW3iunT.Wh1FtvQT70fLQWOtuPueVQJ18q.L6.U5aL5ZPcFqWOQKng6qLOG15iTMhL81oF9t2vHk90ZgvQ5uIbPL.Su_8IdsxorSF3lm_9q79BT
2015-10-26 14:40:12.214 DEBUG [main] (YahooMessengerLoginManager:103) Exchanging PART Token for OAuth
2015-10-26 14:40:12.216 DEBUG [main] (YahooMessengerExchangePARTForOAuthReqResp:61) Sending Request
2015-10-26 14:40:12.216 DEBUG [main] (HttpUtils:32) HTTP GET: https://api.login.yahoo.com/oauth/v2/get_token?oauth_consumer_key=KEY&oauth_signature_method=PLAINTEXT&oauth_nonce=409029&oauth_timestamp=1445888412&oauth_signature=SECRET&oauth_version=1.0&oauth_token=T9pkITxu3AbVKLSwxx_WtWYVhE5eRa_QaIjDJQ0Tu_0zJ2x8I3PwtRLdckayPbSDdcKyteHgzXocgL66790kvZ.rJ1Pt8hIYkaW3iunT.Wh1FtvQT70fLQWOtuPueVQJ18q.L6.U5aL5ZPcFqWOQKng6qLOG15iTMhL81oF9t2vHk90ZgvQ5uIbPL.Su_8IdsxorSF3lm_9q79BT
2015-10-26 14:40:12.536 DEBUG [main] (HttpUtils:59) HTTP Response Code: 200; HTTP Response: oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_token_secret=0251d7aa066d260c02b98678b7d387b397a022f5&oauth_expires_in=3600&oauth_session_handle=AN.GKla2k_9cEzc4j7RMsqkDpxQTh7sbhqQrF.BScR4sSjfWTeAs0Ks-&oauth_authorization_expires_in=701595236&xoauth_yahoo_guid=GWNAZ5CDLDA2M3U55MFLRVETVE
2015-10-26 14:40:12.540 DEBUG [main] (YahooMessengerExchangePARTForOAuthReqResp:65) Response: oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_token_secret=0251d7aa066d260c02b98678b7d387b397a022f5&oauth_expires_in=3600&oauth_session_handle=AN.GKla2k_9cEzc4j7RMsqkDpxQTh7sbhqQrF.BScR4sSjfWTeAs0Ks-&oauth_authorization_expires_in=701595236&xoauth_yahoo_guid=GWNAZ5CDLDA2M3U55MFLRVETVE
2015-10-26 14:40:12.540 DEBUG [main] (YahooMessengerExchangePARTForOAuthReqResp:74) OAuth Token: A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC
2015-10-26 14:40:12.543 DEBUG [main] (YahooMessengerLoginManager:126) Checking for Crumbs
2015-10-26 14:40:12.543 DEBUG [main] (HttpUtils:32) HTTP GET: http://developer.messenger.yahooapis.com/v1/session?realm=yahooapis.com&oauth_consumer_key=KEY&oauth_nonce=814822&oauth_signature_method=PLAINTEXT&oauth_timestamp=1445888412&oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_version=1.0&oauth_signature=SECRET
2015-10-26 14:40:12.666 ERROR [main] (Yahoo:50) Server returned HTTP response code: 401 for URL: http://developer.messenger.yahooapis.com/v1/session?realm=yahooapis.com&oauth_consumer_key=KEY&oauth_nonce=814822&oauth_signature_method=PLAINTEXT&oauth_timestamp=1445888412&oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_version=1.0&oauth_signature=SECRET
java.io.IOException: Server returned HTTP response code: 401 for URL: http://developer.messenger.yahooapis.com/v1/session?realm=yahooapis.com&oauth_consumer_key=KEY&oauth_nonce=814822&oauth_signature_method=PLAINTEXT&oauth_timestamp=1445888412&oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_version=1.0&oauth_signature=SECRET
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1889)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1884)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1883)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1456)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at com.yahoo.messenger.util.HttpUtils.performHttpGet(HttpUtils.java:49)
at com.yahoo.messenger.reqresp.YahooMessengerGetCrumbReqResp.executeRequest(YahooMessengerGetCrumbReqResp.java:52)
at com.yahoo.messenger.manager.YahooMessengerLoginManager.performLoginOAuth(YahooMessengerLoginManager.java:132)
at com.eoxlive.yahoo.Yahoo.connect(Yahoo.java:47)
at com.eoxlive.yahoo.Yahoo.main(Yahoo.java:126)
Caused by: java.io.IOException: Server returned HTTP response code: 401 for URL: http://developer.messenger.yahooapis.com/v1/session?realm=yahooapis.com&oauth_consumer_key=KEY&oauth_nonce=814822&oauth_signature_method=PLAINTEXT&oauth_timestamp=1445888412&oauth_token=A%3D4d1DkcrhoiVBaEq4I2zxn6N4bqp4GCPt7RzV8MK9WLttj9ec3WFbjjY9f73gZexQTr2Iq3Z1lX1NVezL9ns1og1rUkRFTli6BJMmHLWyApC7JNolA5UPIglOg1UwDJpMsFYFlPMuOIxDst75A99gZCvgRA3pFbr1QTZKMUzGhxigI3OZlhXeaADUGFu6Aa9VqtJL8js4A4H9Gtbtf4KDx3L7i9r2s9c_DWvT2ElVrL2WKWekKykeBpZz1jUEU7qMWkVhfWxB8E7EF26QWQbdJtH9N6T1NdR6le0rfBSUqlazf5kvtL83tc89757qkVV9K2v3L4tbtJFussORbflCfMcwCRHVakickpn_Ot51a9JnrSn2iJjKhHL.BRNN_a0nS2qEoLUk1CJxmrbGICDEPkP2UZipROY6ZXrehGsmIhQTV5kKY6vLObmTesn1I_g_FW.IbO7Lb5TeWxZnlVNNWSss9Uo9st8XungEpHgzeX8MqyS9W3sUaqtW.5udmA0D0eaAzli4QQAvEWu5As3BbmSB07d3TM9JUSna7iC3ZM2SOV.mAX6AcaPQOH2VMFeTGFgNRDlIds53Pe8SH_MxjXd4Xil04HX2ZifnejgjoUtJ5doNQAdQ7.oaG2UxKsVC5tgZDx5ujWtC7.IE8xOn.UruC.oCsmfUk4a.Gy_5sP_Tid4YHYSZAW4F0hnbjEa.D2uTOpz1Pf5_gM8eKBTBWnk9dMWkaN9_1hvnaySuz48mbmXqaHZmJvQpygLjxSXpp4.AwG3JytCVIl4xZAYq8.8G16K7mvNKs02nNn9UUkWBo2gC&oauth_version=1.0&oauth_signature=SECRET
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1839)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at com.yahoo.messenger.util.HttpUtils.performHttpGet(HttpUtils.java:48)
... 4 more
curl を使用してみました。最後のクエリを再実行したときの結果は次のとおりです。
jchavez@:~$ curl -i -H "Accept: application/json" "http://developer.messenger.yahooapis.com/v1/session?realm=yahooapis.com&oauth_consumer_key=KEY&oauth_nonce=180910&oauth_signature_method=PLAINTEXT&oauth_timestamp=1445888210&oauth_token=A%3DvYIEmCjvpCWFWeDYUflyWF0..Fw7kgzfULzFv4LkLBM3l3MAIdGwcLgJ0QcRkITuqfOF9RWWZwQddfgrxtTYi0Ha4Lwr8drPTtPYBerrtZxSGd9BEfNd4rHeD9z8KsIZZ1_6DfSisJwEda0fbHnJTvEr1WhE_24yI7LePfC7i7Lr3wlFDvLO7e5GJmLLvcu133OycY8cO6gJDdMtinMmFBOVObJqpSbqNIZVGQSL1ckjoHsAg0HtNYJGt2EHIt7z4JIV5qNt8B.UfGcOgje_MBZsALA4K5edVYfh_VzznQ9sCpqjuUKZPrV4P9Egr8cPmKnNN_HP5_3dkQPDErF_lOeOguRutoJUSsOxPLylUof3GY4nS4UEVmoz_ahI7n2qIjj6v0gSwq_Ec4W7c1xUKyFr3CgFEcMPRm8PQKffulyf3p3XxQS1wA.oJFBDXAld91wtiW00vkGHPQM9h9aHmXZnpMtr3H2hzX3ZC5JOaPgJ7tXX_S52xE5b02Lr7tc.iTsnBsaAnK.t4a2Uo7mc3PoXzgkdzV70Dyy.sM_QLEV6JSV30uP8rBqjDeDAl84e3_KCDwM9BleEdSrAdHTNuEo4z_WX4_txyXIUNsO6Jbfc5ChHGUnDwXYoT8vzmpK315G7sG.5v7LIK22R3TKxPVyhXc_CkIA.OFRn1vWd_WEEOhaPqx9Fx9dmPjHeeC7YI6yCy9HVx6QvaB4AsqQnEInR7SH0CgOWFyGIr_N7OVCCLKApmNw31ZLhw2HCxNdBoqSiFpCsVosvXHKEjnCHI21jcwaStiLAc004yppgLD2EnCW1&oauth_version=1.0&oauth_signature=SECRET"
HTTP/1.1 401 Authorization Required
Date: Mon, 26 Oct 2015 19:45:54 GMT
WWW-Authenticate: OAuth oauth_problem="signature_invalid", realm="yahooapis.com"
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: application/json
Cache-Control: private
{"error":{"lang":"en-US","description":"Please provide valid credentials. OAuth oauth_problem=\"signature_invalid\", realm=\"yahooapis.com\""}}
Yahoo API の使用に成功した人はいますか?
ありがとう、
JC