Module: CloudAlly::Authentication
- Included in:
- API
- Defined in:
- lib/cloudally/authentication.rb
Overview
Deals with authentication flow and stores it within global configuration
Instance Method Summary collapse
-
#auth(options = {}) ⇒ Object
(also: #login)
Authorize to the CloudAlly portal and return access_token.
-
#auth_partner(options = {}) ⇒ Object
(also: #partner_login)
Authorize to the partner portal and return access_token.
-
#auth_refresh(token) ⇒ Object
Return an access token from authorization.
Instance Method Details
#auth(options = {}) ⇒ Object Also known as: login
Authorize to the CloudAlly portal and return access_token
8 9 10 11 12 13 |
# File 'lib/cloudally/authentication.rb', line 8 def auth( = {}) raise raise ConfigurationError.new "client_id and/or client_secret empty" unless client_id && client_secret api_auth('/auth', ) rescue Faraday::UnauthorizedError => e raise AuthenticationError.new e.to_s end |
#auth_partner(options = {}) ⇒ Object Also known as: partner_login
Authorize to the partner portal and return access_token
24 25 26 27 28 29 |
# File 'lib/cloudally/authentication.rb', line 24 def auth_partner( = {}) raise raise ConfigurationError.new "client_id and/or client_secret empty" unless client_id && client_secret api_auth('/auth/partner', ) rescue Faraday::ServerError, Faraday::UnauthorizedError => e raise AuthenticationError.new e.to_s end |
#auth_refresh(token) ⇒ Object
Return an access token from authorization
17 18 19 20 21 |
# File 'lib/cloudally/authentication.rb', line 17 def auth_refresh(token) api_refresh('/auth/refresh', token) rescue Faraday::UnauthorizedError => e raise AuthenticationError.new e.to_s end |