Method: Misty::Auth#authenticate

Defined in:
lib/misty/auth.rb

#authenticateObject



32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/misty/auth.rb', line 32

def authenticate
  Misty::HTTP::NetHTTP.http_request(
    @uri, ssl_verify_mode: @config.ssl_verify_mode, log: @config.log
  ) do |connection|
    response = connection.post(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