lib/fluent/plugin/out_rackspace_cloud_feeds.rb
##
# either get a token back from identity, or poop the pants
# noinspection RubyStringKeysInHashInspection
either get a token back from identity, or poop the pants
noinspection RubyStringKeysInHashInspection
either get a token back from identity or poop the pants noinspection RubyStringKeysInHashInspection
def authenticate_user
    uri = URI @identity_endpoint
    http = Net::HTTP.new(uri.host, uri.port)
    if uri.scheme == 'https'
      http.use_ssl = true
    end
    req = Net::HTTP::Post.new(uri.path)
    content = {
        'auth' => {
            'passwordCredentials' => {
                'username' => @identity_username,
                'password' => @identity_password
            }
        }
    }
    req.body = content.to_json
    req['content-type'] = 'application/json'
    req['accept'] = 'application/json'
    res = http.request(req)
    case res
      when Net::HTTPSuccess
        JSON.parse(res.body)['access']['token']['id']
      else
        raise "Unable to authenticate with identity at #{@identity_endpoint} as #{@identity_username}"
    end
  end
def authenticate_user uri = URI @identity_endpoint http = Net :: HTTP . new ( uri . host , uri . port ) if uri . scheme == 'https' http . use_ssl = true end req = Net :: HTTP :: Post . new ( uri . path ) content = { 'auth' => { 'passwordCredentials' => { 'username' => @identity_username , 'password' => @identity_password } } } req . body = content . to_json req [ 'content-type' ] = 'application/json' req [ 'accept' ] = 'application/json' res = http . request ( req ) case res when Net :: HTTPSuccess JSON . parse ( res . body ) [ 'access' ] [ 'token' ] [ 'id' ] else raise "Unable to authenticate with identity at #{@identity_endpoint} as #{@identity_username}" end end
either get a token back from identity, or poop the pants
noinspection RubyStringKeysInHashInspection
either get a token back from identity or poop the pants noinspection RubyStringKeysInHashInspection
# Get the token