Class: NewlineHw::Token
- Inherits:
-
Object
- Object
- NewlineHw::Token
- Defined in:
- lib/newline_hw/token.rb
Constant Summary collapse
- NETRC_KEY =
"newline.theironyard.com"
Class Method Summary collapse
Class Method Details
.decode(token) ⇒ Object
8 9 10 11 |
# File 'lib/newline_hw/token.rb', line 8 def self.decode(token) payload = JWT.decode(token, nil, false) payload[0] end |
.get_for_path ⇒ Object
13 14 15 16 |
# File 'lib/newline_hw/token.rb', line 13 def self.get_for_path path_config = YAML.load_file(".path.config") path_config["token"] end |
.get_for_user ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/newline_hw/token.rb', line 18 def self.get_for_user return ENV["NEWLINE_API_TOKEN"] if ENV["NEWLINE_API_TOKEN"] if (netrc = netrc_file[NETRC_KEY]) netrc["password"] else raise NewlineHw::AuthenticationError, "No stored credentials or ENV[\"NEWLINE_API_TOKEN\"]" end end |