Sha256: 826fa842a27a1be0f2e2c5471cf8fd994eacf7cae2b5115a2f72647e712d17de

Contents?: true

Size: 745 Bytes

Versions: 3

Compression:

Stored size: 745 Bytes

Contents

module Doorkeeper
  module OAuth
    class InvalidTokenResponse < ErrorResponse
      def self.from_access_token(access_token, attributes = {})
        reason = case
          when access_token.try(:revoked?)
            :revoked
          when access_token.try(:expired?)
            :expired
          else
            :unknown
          end

        new(attributes.merge(:reason => reason))
      end

      def initialize(attributes = {})
        super(attributes.merge(:name => :invalid_token, :state => :unauthorized))
        @reason = attributes[:reason] || :unknown
      end

      def description
        @description ||= I18n.translate @reason, :scope => [:doorkeeper, :errors, :messages, :invalid_token]
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
doorkeeper-1.1.0 lib/doorkeeper/oauth/invalid_token_response.rb
doorkeeper-1.0.0 lib/doorkeeper/oauth/invalid_token_response.rb
doorkeeper-1.0.0.rc2 lib/doorkeeper/oauth/invalid_token_response.rb