Sha256: 689e6fbd757da42f2b4cd9d28827a0291bacd8828fe711f07f4f00a82e6271d2

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 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

1 entries across 1 versions & 1 rubygems

Version Path
doorkeeper-1.2.0 lib/doorkeeper/oauth/invalid_token_response.rb