Sha256: 25402b827e3ca6fb59551076e19fffd652f3cdbc45c39bbb1119a05fb48ea5af

Contents?: true

Size: 871 Bytes

Versions: 18

Compression:

Stored size: 871 Bytes

Contents

require "securerandom"

module TokenHelpers
  # Creates a cached access token for the config directly to disk
  def cache_access_token(config, token)
    File.write(config.access_token_filename, token)
  end

  # Creates a cached refresh token for the config directly to disk
  def cache_refresh_token(config, token)
    File.write(config.refresh_token_filename, token)
  end

  # Returns the cached access token for the config directly from disk
  def cached_access_token(config)
    File.read(config.access_token_filename).chomp
  end

  # Returns the cached refresh token for the config directly from disk
  def cached_refresh_token(config)
    File.read(config.refresh_token_filename).chomp
  end

  # This returns a token like string with no meaning but should always be
  # different so never clashes in tests.
  def random_token
    SecureRandom.hex(20)
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0 spec/support/token_helpers.rb
brightbox-cli-5.0.0.rc2 spec/support/token_helpers.rb
brightbox-cli-5.0.0.rc1 spec/support/token_helpers.rb
brightbox-cli-5.0.0.alpha spec/support/token_helpers.rb
brightbox-cli-4.8.0 spec/support/token_helpers.rb
brightbox-cli-4.7.0 spec/support/token_helpers.rb
brightbox-cli-4.6.0 spec/support/token_helpers.rb
brightbox-cli-4.5.0 spec/support/token_helpers.rb
brightbox-cli-4.5.0.rc1 spec/support/token_helpers.rb
brightbox-cli-4.4.0 spec/support/token_helpers.rb
brightbox-cli-4.3.2 spec/support/token_helpers.rb
brightbox-cli-4.3.1 spec/support/token_helpers.rb
brightbox-cli-4.3.0 spec/support/token_helpers.rb
brightbox-cli-4.2.1 spec/support/token_helpers.rb
brightbox-cli-4.2.0 spec/support/token_helpers.rb
brightbox-cli-4.1.0 spec/support/token_helpers.rb
brightbox-cli-4.0.0 spec/support/token_helpers.rb
brightbox-cli-4.0.0.rc2 spec/support/token_helpers.rb