Class: Sitefull::Cloud::Auth

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sitefull-cloud/auth.rb

Instance Method Summary collapse

Constructor Details

#initialize(auth_type, options = {}) ⇒ Auth

Returns a new instance of Auth.



10
11
12
# File 'lib/sitefull-cloud/auth.rb', line 10

def initialize(auth_type, options = {})
  @auth = auth_class(auth_type).new(options)
end

Instance Method Details

#authorization_urlObject



14
15
16
# File 'lib/sitefull-cloud/auth.rb', line 14

def authorization_url
  token.authorization_uri(authorization_url_options)
end

#authorize!(code) ⇒ Object



18
19
20
21
# File 'lib/sitefull-cloud/auth.rb', line 18

def authorize!(code)
  token.code = code
  token.fetch_access_token!
end

#credentialsObject



27
28
29
30
31
# File 'lib/sitefull-cloud/auth.rb', line 27

def credentials
  return @credentials unless @credentials.nil?
  token.refresh!
  @credentials = @auth.credentials(token)
end

#tokenObject



23
24
25
# File 'lib/sitefull-cloud/auth.rb', line 23

def token
  @token ||= Signet::OAuth2::Client.new(token_options)
end