Method: Misty::Auth#authenticate

Defined in:
lib/misty/auth.rb

#authenticateObject



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/misty/auth.rb', line 40

def authenticate
  Misty::HTTP::NetHTTP.http_request(
    @uri, ssl_verify_mode: @config.ssl_verify_mode, log: @config.log
  ) do |connection|
    response = connection.post(self.class.path, @credentials.to_json,
      { 'Content-Type' => 'application/json', 'Accept' => 'application/json' })
    unless response.code =~ /200|201/
      raise AuthenticationError, "Response code=#{response.code}, Msg=#{response.msg}"
    end
    response
  end
end