Sha256: e3259e9f4f12f5e339f0a65ca10aa1959c73fb4e1647fa181e587405b65cc412

Contents?: true

Size: 700 Bytes

Versions: 25

Compression:

Stored size: 700 Bytes

Contents

module ResoTransport
  module Authentication
    # A simple auth strategy that uses a static, non-expiring token.
    class StaticTokenAuth < AuthStrategy
      attr_reader :access_token
      attr_reader :token_type

      def initialize(options)
        @access_token = options.fetch(:access_token)
        @token_type   = options.fetch(:token_type, "Bearer")
      end

      # Simply returns a static, never expiring access token
      # @return [Access] The access token object
      def authenticate
        Access.new(
          access_token: access_token,
          token_type: token_type,
          expires_in: 1 << (1.size * 8 - 2) - 1 # Max int value
        )
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
reso_transport-2.0.0 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.19 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.18 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.17 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.16 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.15 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.14 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.13 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.12 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.11 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.9 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.8 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.7 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.5 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.4 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.3 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.2 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.5.1 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.4.0 lib/reso_transport/authentication/static_token_auth.rb
reso_transport-1.3.2 lib/reso_transport/authentication/static_token_auth.rb