Sha256: 56fa39a7c0b4f17d49f69cf575e7a24e0f25459df2449a1a3bcec5f2cb2ccbf7

Contents?: true

Size: 991 Bytes

Versions: 3

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

require_relative 'auth_strategy'

module Redd
  module AuthStrategies
    # A password-based authentication scheme. Requests all scopes.
    class Script < AuthStrategy
      def initialize(client_id:, secret:, username:, password:, **kwargs)
        super(client_id: client_id, secret: secret, **kwargs)
        @username = username
        @password = password
      end

      # Perform authentication and return the resulting access object
      # @return [Access] the access token object
      def authenticate
        request_access('password', username: @username, password: @password)
      end

      # Since the access isn't used for refreshing, the strategy is inherently
      # refreshable.
      # @return [true]
      def refreshable?(_access)
        true
      end

      # Refresh the authentication and return the refreshed access
      # @return [Access] the new access
      def refresh(_)
        authenticate
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redd-0.9.0.pre.3 lib/redd/auth_strategies/script.rb
redd-0.9.0.pre.2 lib/redd/auth_strategies/script.rb
redd-0.9.0.pre.1 lib/redd/auth_strategies/script.rb