Howto use Ruby to login to RTC 5.X
I am trying to login to RTC using Ruby, I have tried using both HTTParty and RestClient and have seen the examples below:
https://jazz.net/forum/questions/106700/connecting-to-rtc-4x-using-ruby
We are running RTC 5.0
My rtc_url is https://CNAME/jazz
My Ruby login code is very simple:
puts "Authenticating..."
response = RestClient.get("#{rtc_url}/authenticated/identity")
p response.headers[:x_com_ibm_team_repository_web_auth_msg]
if response.headers[:x_com_ibm_team_repository_web_auth_msg] == 'authrequired'
puts "Not currently authenticated: Sending username and password..."
cookie = response.headers['Set-Cookie']
RestClient.get("#{rtc_url}/authenticated/j_security_check",
:query => { "j_username" => "EPLSWRTC", "j_password" => "nCCAuto2"},
:headers => {'Cookie' => response.headers['Set-Cookie']}) { |response, request, result, &block|
if [301, 302, 307].include? response.code
response.follow_redirection(request, result, &block)
else
response.return!(request, result, &block)
end
}
p response
p response.headers
if response.headers[:x_com_ibm_team_repository_web_auth_msg] == 'authrequired'
abort "Authentication failed"
end
puts "Authentication successful"
cookie = cookie + ", " + response.headers['Set-Cookie']
end
end
However when I try I keep getting the following replies
#<HTTParty::Response:0x20e94b0 parsed_response="<!DOCTYPE html>\n\n<!--\n\n Licensed Materials - Property of IBM\n (c) Copyright IBM Corporation 2005-2013. All Rights Reserved.\n \n Note to U.S. Government Users Restricted Rights:\n Use, duplication or disclosure restricted by GSA ADP Schedule\n Contract with IBM Corp.\n \n-->\n\n<html >\n\n<head>\n<meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=10\">\n<title></title>\n\n<link type=\"text/css\" rel=\"stylesheet\" href=\"/jazz/web/_style/?include=C~&etag=I6YBZn18xJI_en_US&_proxyURL=%2Fjazz&ss=Funon\">\n<link rel=\"shortcut icon\" href=\"/jazz/web/net.jazz.ajax/jazz.ico\">\n\n<style type=\"text/css\">\n#net-jazz-ajax-NoScriptMessage {\n\twidth: 100%;\n\tcolor: #D0D0D0;\n\tfont-size: 2em;\n\ttext-align: center;\n\tposition: absolute;\n\ttop: 1%;\n\tz-index: 999;\n}\n</style>\n\n</head>\n\n<body class=\"claro\">\n\t<noscript><div id=\"net-jazz-ajax-NoScriptMessage\">Javascript is either disabled or not available in your Browser</div></noscript>\n\t<div id=\"net-jazz-ajax-InitialLoadMessage\">Loading...</div>\n\t<div id=\"net-jazz-ajax-WorkbenchRoot\"></div>\n\t\n\t<script type=\"text/javascript\">\n\t\tdjConfig = {\n\t\t\tisDebug: false,\n\t\t\tusePlainJson: true,\n\t\t\tbaseUrl: \"/jazz/web/dojo/\",\n\t\t\tlocale: \"en-us\",\n\t\t\tlocalizationComplete: true\n\t\t};\n\t\t/*null*/\n\t\tnet = {jazz: {ajax: {}}};\n\t\tnet.jazz.ajax._contextRoot = \"/jazz\";\n\t\tnet.jazz.ajax._appPath = \"/jazz/auth/authrequired\";\n\t\tnet.jazz.ajax._webuiPrefix = \"/web/\";\n\t</script>\n\t\n\t<script type=\"text/javascript\" src=\"/jazz/web/_js/?include=C~&etag=I6YBZn18xJI_en_US&_proxyURL=%2Fjazz&ss=Funon&locale=en-us\"></script>\n\n<script type=\"text/javascript\">\nrequire(\"dojo/main\").getObject('jazz.core.loader', true)._serverStartup=\"Funon\";\nrequire(\"dojo/main\").getObject('jazz.core.loader',true)._loaded=[\"C\"];\n</script>\n\n\t\n\t<script type=\"text/javascript\">\n\t/* <![CDATA[ */\n\t\tdojo.addOnLoad( function() {\n\t\t\tnet.jazz.ajax.ui.PlatformUI.createAndRunWorkbench(\"net.jazz.web.app.authrequired\");\n\t\t});\n\t/* ]]> */\n\t</script>\n</body>\n</html>\n", @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"date"=>["Thu, 22 Jan 2015 08:10:56 GMT"], "x-powered-by"=>["Servlet/3.0"], "x-com-ibm-team-repository-web-auth-msg"=>["authrequired"], "set-cookie"=>["JazzFormAuth=Form; Path=/jazz"], "expires"=>["Thu, 01 Dec 1994 16:00:00 GMT"], "cache-control"=>["no-cache=\"set-cookie, set-cookie2\""], "connection"=>["close"], "transfer-encoding"=>["chunked"], "content-type"=>["text/html; charset=UTF-8"], "content-language"=>["en-US"]}>