Sha256: 9674866bfebd5b3442b5f20dbae43708840656db15695bf866f4e471705a071d

Contents?: true

Size: 566 Bytes

Versions: 1

Compression:

Stored size: 566 Bytes

Contents

require 'multi_json'

module OmniAuth
  module Hotmart
    class AccessTokenMiddleware

      attr_reader :options

      def initialize(app, options={})
        @app = app
        @options = options
      end

      def call(request_env)
        if request_env.url.path == "/oauth/access_token"
          @app.call(request_env).on_complete do |response_env| 
            response_env.body =  MultiJson.dump(MultiJson.load(response_env.body)["TokenResponse"])
          end
        else
          @app.call(request_env)
        end
      end
      
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-hotmart-1.0.1 lib/omniauth-hotmart/access_token_middleware.rb