Sha256: 5c245a187c79f5d5e05c27dec0c501d46a76469d7384ad6c79c54e1a1bce1827

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

require '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 = JSON.generate(JSON.parse(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.0 lib/omniauth-hotmart/access_token_middleware.rb