Class: Rackconnect::Auth
- Inherits:
-
Object
- Object
- Rackconnect::Auth
- Defined in:
- lib/rackconnect/lib/auth.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Auth
constructor
A new instance of Auth.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Auth
Returns a new instance of Auth.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rackconnect/lib/auth.rb', line 3 def initialize(={}) api_key = [:api_key] username = [:username] params = { :auth => { "RAX-KSKEY:apiKeyCredentials" => { "apiKey" => api_key, "username" => username } } }.to_json resp = RestClient.post Rackconnect::IDENTITY_URL, params, content_type: :json, accept: :json body = JSON.parse(resp) Rackconnect.token = body["access"]["token"]["id"] Rackconnect.tenant_id = body["access"]["token"]["tenant"]["id"] end |
Instance Method Details
#to_s ⇒ Object
23 24 25 |
# File 'lib/rackconnect/lib/auth.rb', line 23 def to_s {auth_token: Rackconnect.token, tenant_id: Rackconnect.tenant_id} end |