Sha256: e4eba8459b32e9f3682a0e31e2905cef1b44fe1e6fabd2e28d33e2f53bd76561

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

module Doorkeeper
  module OAuth
    class InvalidTokenResponse < ErrorResponse
      attr_reader :reason

      def self.from_access_token(access_token, attributes = {})
        reason = if access_token.try(:revoked?)
                   :revoked
                 elsif 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
        scope = { scope: [:doorkeeper, :errors, :messages, :invalid_token] }
        @description ||= I18n.translate @reason, scope
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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