Sha256: a29a01e782d918eae10c6222444a1c14f0d958ee4a6ee2c0aa34c23e0c716880

Contents?: true

Size: 649 Bytes

Versions: 10

Compression:

Stored size: 649 Bytes

Contents

module EventMachine
  module Middleware
    class OAuth2
      include EM::HttpEncoding
      attr_accessor :access_token

      def initialize(opts={})
        self.access_token = opts[:access_token] or raise "No :access_token provided"
      end

      def request(client, head, body)
        uri = client.req.uri.dup
        update_uri! uri
        client.req.set_uri uri

        [head, body]
      end

      def update_uri!(uri)
        if uri.query.nil?
          uri.query = encode_param(:access_token, access_token)
        else
          uri.query += "&#{encode_param(:access_token, access_token)}"
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
em-http-request-samesite-0.1.1 lib/em-http/middleware/oauth2.rb
em-http-request-samesite-1.1.7 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.7 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.6 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.5 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.4 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.3 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.2 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.1 lib/em-http/middleware/oauth2.rb
em-http-request-1.1.0 lib/em-http/middleware/oauth2.rb