Method: ElsToken::ClassMethods#authenticate
- Defined in:
- lib/els_token.rb
#authenticate(username, password, options = {}) ⇒ Object
authenticates against ELS and returns the user token
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/els_token.rb', line 73 def authenticate(username,password,={}) begin response = els_http_request("/authenticate", {"uri"=>"realm=aolcorporate","username"=>"#{username}","password"=>"#{password}"}, ) if response.code.eql? "200" # return the token response.body.chomp.sub(/token\.id=/,"") else raise response.error! end rescue Net::HTTPExceptions => e1 raise e1, "token retrieval failed for #{username}" rescue Exception => e # Do not expect these. Wrapping the exception so # as to not reveal the passed in password puts e.backtrace raise e, "unable to fetch token for #{username}" end end |