Sha256: 9c7a0b127a5246ed0368080a6f47bac3d5c85be4401360e88d95cea5d410eda6
Contents?: true
Size: 693 Bytes
Versions: 1
Compression:
Stored size: 693 Bytes
Contents
module Tito class OAuth2Middleware < FaradayMiddleware::OAuth2 def call(env) token = if @token.is_a?(Proc) @token.call(env) else @token end token ||= Tito.api_key params = query_params(env[:url]) if token.respond_to?(:empty?) && !token.empty? env[:url].query = build_query params env[:request_headers][AUTH_HEADER] ||= %(Bearer #{token}) end @app.call env end def initialize(app, token = nil, options = {}) super(app) options, token = token, nil if token.is_a? Hash @token = token raise ArgumentError, ":param_name can't be blank" if @param_name.empty? end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tito-0.1.3 | lib/tito/oauth2_middleware.rb |