Class: KOSapiClient::OAuth2HttpAdapter
- Inherits:
-
Object
- Object
- KOSapiClient::OAuth2HttpAdapter
- Defined in:
- lib/kosapi_client/oauth2_http_adapter.rb
Constant Summary collapse
- DEFAULT_AUTH_URL =
'https://auth.fit.cvut.cz/oauth/authorize'
- DEFAULT_TOKEN_URL =
'https://auth.fit.cvut.cz/oauth/token'
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
-
#initialize(credentials, base_url, opts = {}) ⇒ OAuth2HttpAdapter
constructor
A new instance of OAuth2HttpAdapter.
- #send_request(verb, url, options = {}) ⇒ Object
Constructor Details
#initialize(credentials, base_url, opts = {}) ⇒ OAuth2HttpAdapter
Returns a new instance of OAuth2HttpAdapter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kosapi_client/oauth2_http_adapter.rb', line 11 def initialize(credentials, base_url, opts = {}) @base_url = base_url @credentials = credentials auth_url = opts[:auth_url] || DEFAULT_AUTH_URL token_url = opts[:token_url] || DEFAULT_TOKEN_URL connection_opts = opts[:connection_opts] || {} MultiXml.parser = :ox # make sure to use Ox because of different namespace handling in other MultiXML parsers @client = OAuth2::Client.new( credentials[:client_id], credentials[:client_secret], auth_scheme: :basic_auth, site: base_url, authorize_url: auth_url, token_url: token_url, connection_opts: connection_opts) end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/kosapi_client/oauth2_http_adapter.rb', line 9 def base_url @base_url end |
Instance Method Details
#send_request(verb, url, options = {}) ⇒ Object
28 29 30 31 |
# File 'lib/kosapi_client/oauth2_http_adapter.rb', line 28 def send_request(verb, url, = {}) raise 'No credentials set' if @credentials.empty? token.request(verb, url, ) end |