Sha256: cf80cc690d948bd50b7f5f5a7df70b5b7beb6119596fb825d7952e5abb795711
Contents?: true
Size: 1.53 KB
Versions: 3
Compression:
Stored size: 1.53 KB
Contents
module CloudAlly # Deals with authentication flow and stores it within global configuration module Authentication # Authorize to the CloudAlly portal and return access_token def auth(options = {}) params = access_token_params.merge(options) response = post("/auth", params) # return access_token process_token(response.body) end alias login auth # Return an access token from authorization def auth_refresh(token) params = { refreshToken: token } response = post("/auth/refresh", params) # return access_token process_token(response.body) end # Authorize to the partner portal and return access_token def auth_partner(options = {}) params = access_token_params.merge(options) response = post("/auth/partner", params) # return access_token process_token(response.body) end alias partner_login auth_partner private def access_token_params { email: username, password: password } end def process_token(response) at = nil CloudAlly.configure do |config| at = config.access_token = response["accessToken"] config.token_type = response["tokenType"] config.refresh_token = response["refreshToken"] config.token_expires = response["expiresIn"] end raise StandardError.new 'Could not find valid accessToken; response ' + response.to_s if at == '' || at.nil? at end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cloudally-0.2.0 | lib/cloudally/authentication.rb |
cloudally-0.1.3 | lib/cloudally/authentication.rb |
cloudally-0.1.2 | lib/cloudally/authentication.rb |