Sha256: 9a55157bcd636b153a8e77ecc9c2a7d9ab231cf95e1656aa9a251360b49c0c7a
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
module Pickpocket module Authentication class TokenHandler attr_accessor :logger def initialize @logger = Pickpocket::Logger end def save_oauth(token) save_token(token: token, path: Pickpocket.config.oauth_token_file) end def save_auth(token) save_token(token: token, path: Pickpocket.config.authorization_token_file) end def read_oauth read_token(path: Pickpocket.config.oauth_token_file, error_message: 'OAuth Token file does not exist. Make sure you request authorization before proceeding.') end def read_auth read_token(path: Pickpocket.config.authorization_token_file, error_message: 'Authorization Token file does not exist. Make sure you request authorization before proceeding.') end private def save_token(token:, path:) FileUtils.mkdir_p(Pickpocket.config.home_folder) file = File.new(path, 'w') file.write(token) file.close end def read_token(path:, error_message:) file = File.new(path, 'r') file.read rescue Errno::ENOENT => _ logger.warn(error_message) :no_token end end end end
Version data entries
9 entries across 9 versions & 1 rubygems