Sha256: 30546a798b1b3197b9a7e2762ca06e8a27d6c8c20f6d02a212f77b274461a4c1

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

module Rack
  module OAuth2
    class AccessToken
      include AttrRequired, AttrOptional
      attr_required :access_token, :token_type, :client
      attr_optional :refresh_token, :expires_in, :scope
      delegate :get, :post, :put, :delete, :to => :client

      def initialize(attributes = {})
        (required_attributes + optional_attributes).each do |key|
          self.send :"#{key}=", attributes[key]
        end
        @token_type = self.class.to_s.split('::').last.underscore.to_sym
        @client = HTTPClient.new
        @client.request_filter << Authenticator.new(self)
        attr_missing!
      end

      def token_response(options = {})
        {
          :access_token => access_token,
          :refresh_token => refresh_token,
          :token_type => token_type,
          :expires_in => expires_in,
          :scope => Array(scope).join(' ')
        }
      end
    end
  end
end

require 'rack/oauth2/access_token/authenticator'
require 'rack/oauth2/access_token/bearer'
require 'rack/oauth2/access_token/mac'
require 'rack/oauth2/access_token/legacy'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rack-oauth2-0.8.0 lib/rack/oauth2/access_token.rb
rack-oauth2-0.8.0.alpha lib/rack/oauth2/access_token.rb