Hello,
This implements a basic OAuth client. It's fairly useless by itself, and the intention
is that it will be extended by other classes -- e.g., you'd implement a FactoryClient
that includes this code.
By default, it will check config/settings.yml for a key under oauth: with the name of the
host. I included a commented-out example. If this is not to your liking, you're free
to implement your own consumer_credentials_for_resource, and to customize default_headers.
(For example, in Katello, you might want default_headers to return {'katello-user'
=> 'admin'}.)
As an open question: Where should this code live? I've placed it in Conductor, but
I'm wondering if it might actually belong in aeolus-image, which is likely going to be
the primary consumer of OAuth providers.
None of the providers we wish to consume using OAuth -- iwhd, Factory, or Config Server --
have OAuth support just yet. However, it should be trivial to implement new clients once
they're ready.
I don't have tests ready yet, but wanted to get this on the list for review sooner
rather than later.
Sample usage:
require 'oauth_client'
o =
OAuthClient.new('http://www.example.com/')
o.authenticated_get('/api/providers')
puts o.body
Best,
Matt