class Sitefull::Cloud::Auth

Public Class Methods

new(auth_type, options = {}) click to toggle source
# File lib/sitefull-cloud/auth.rb, line 10
def initialize(auth_type, options = {})
  @auth = auth_class(auth_type).new(options)
end

Public Instance Methods

authorization_url() click to toggle source
# File lib/sitefull-cloud/auth.rb, line 14
def authorization_url
  token.authorization_uri(authorization_url_options)
end
authorize!(code) click to toggle source
# File lib/sitefull-cloud/auth.rb, line 18
def authorize!(code)
  token.code = code
  token.fetch_access_token!
end
credentials() click to toggle source
# File lib/sitefull-cloud/auth.rb, line 27
def credentials
  return @credentials unless @credentials.nil?
  token.refresh!
  @credentials = @auth.credentials(token)
end
token() click to toggle source
# File lib/sitefull-cloud/auth.rb, line 23
def token
  @token ||= Signet::OAuth2::Client.new(token_options)
end

Private Instance Methods

auth_class(auth_type) click to toggle source
# File lib/sitefull-cloud/auth.rb, line 35
def auth_class(auth_type)
  require "sitefull-cloud/auth/#{auth_type}"
  Kernel.const_get "Sitefull::Auth::#{auth_type.capitalize}"
end