Module: OnlyofficeDigitaloceanWrapper::TokenMethods
- Included in:
- DigitalOceanWrapper
- Defined in:
- lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb
Overview
Methods to login in account
Instance Method Summary collapse
-
#correct_access_token? ⇒ true, false
Check if access token is correct.
-
#read_token(token_file_path: "#{Dir.home}/.do/access_token", force_file_read: false) ⇒ String
Read access token from file system.
Instance Method Details
#correct_access_token? ⇒ true, false
Check if access token is correct
8 9 10 11 12 13 14 15 |
# File 'lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb', line 8 def correct_access_token? begin @client.droplets.all.first rescue DropletKit::Error return false end true end |
#read_token(token_file_path: "#{Dir.home}/.do/access_token", force_file_read: false) ⇒ String
Read access token from file system
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/onlyoffice_digitalocean_wrapper/digitalocean_wrapper/token_methods.rb', line 21 def read_token(token_file_path: "#{Dir.home}/.do/access_token", force_file_read: false) # rubocop:disable Style/FetchEnvVar return ENV['DO_ACCESS_TOKEN'] if ENV.key?('DO_ACCESS_TOKEN') && !force_file_read # rubocop:enable Style/FetchEnvVar File.read(token_file_path).delete("\n") rescue Errno::ENOENT raise Errno::ENOENT, "No access token found in #{token_file_path}. " \ "Please create file #{token_file_path} with token" end |