Sha256: f8a7c8fe35cfcf7f56c2e41e8dc263df99acb99d2c3703766fe57f319d133435

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

module Rack
  module OAuth2
    class AccessToken
      include AttrRequired, AttrOptional
      attr_required :access_token, :token_type
      attr_optional :refresh_token, :expires_in, :scope

      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
        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/bearer'
require 'rack/oauth2/access_token/mac'

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rack-oauth2-0.6.4 lib/rack/oauth2/access_token.rb
rack-oauth2-0.6.3 lib/rack/oauth2/access_token.rb
rack-oauth2-0.6.2 lib/rack/oauth2/access_token.rb
rack-oauth2-0.6.1 lib/rack/oauth2/access_token.rb
rack-oauth2-0.6.0 lib/rack/oauth2/access_token.rb
rack-oauth2-0.6.0.alpha lib/rack/oauth2/access_token.rb