Class: MyExperimentREST::SessionCookie

Inherits:
Object
  • Object
show all
Defined in:
lib/myexperiment-rest/authentication.rb

Overview

Connects to myExperiment REST API and creates a session cookie object that can be used for basic authentication.

Class Method Summary collapse

Class Method Details

Returns a session cookie as a string.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/myexperiment-rest/authentication.rb', line 12

def self.create_session_cookie(username, password)
  begin
    # Create a session cookie
    response = RestClient.post("#{Urls::MYEXPERIMENT_URL}/#{Urls::SESSION_URL}",
                                     "<session><username>#{username}</username><password>#{password}</password></session>",
                                     {:content_type => 'application/xml'} )
    response.cookies 
  rescue Exception => e
    raise "REST call to acquire workflow resource failed!\n" + e
  end

end