Class: Rack::OauthProxy::Client
- Inherits:
-
Object
- Object
- Rack::OauthProxy::Client
- Defined in:
- lib/rack/oauth_proxy/client.rb,
lib/rack/oauth_proxy/client/request.rb,
lib/rack/oauth_proxy/client/response.rb
Defined Under Namespace
Classes: NoUrlError, Request, Response
Constant Summary collapse
- READ_TIMEOUT =
1
- OPEN_TIMEOUT =
1
Instance Method Summary collapse
- #fetch(env) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/rack/oauth_proxy/client.rb', line 9 def initialize( = {}) @options = end |
Instance Method Details
#fetch(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rack/oauth_proxy/client.rb', line 13 def fetch(env) request = Request.new(env) if request.has_any_valid_credentials? path = "#{uri.path}" path << "?#{request.to_query}" if request.to_query.present? header = { "Authorization" => request., "Host" => host, "Resource-Owner-Id" => request.resource_owner_id, "Scopes" => request.scopes, }.reject {|key, value| value.nil? } raw_response = http_client.get(path, header) response = Response.new(raw_response) if response.valid_as_access_token? AccessTokens::Valid.new(response.to_hash) else AccessTokens::Invalid.new end else AccessTokens::Invalid.new end rescue Timeout::Error AccessTokens::Invalid.new end |