Class GoogleCalendar::Service
In: lib/googlecalendar/service.rb
Parent: ServiceBase

This class interacts with google calendar service. If you want to use ClientLogin for authentication, use this class. If you want to use AuthSub, use ServiceAuthSub.

Methods

Constants

AUTH_PATH = "/accounts/ClientLogin"   Server Path to authenticate

Public Class methods

[Source]

    # File lib/googlecalendar/service.rb, line 14
14:     def initialize(email, pass)
15:       @email = email
16:       @pass = pass
17:       @session = nil
18:       @cookie = nil
19:       @auth = nil
20:     end

Private Instance methods

[Source]

    # File lib/googlecalendar/service.rb, line 45
45:     def add_authorize_header(header)
46:       header["Authorization"] = "GoogleLogin auth=#{@auth}"
47:     end

[Source]

    # File lib/googlecalendar/service.rb, line 23
23:     def auth
24:       https = Net::HTTP.new(AUTH_SERVER, 443, @@proxy_addr, @@proxy_port, @@proxy_user, @@proxy_pass)
25:       https.use_ssl = true
26:       https.verify_mode = OpenSSL::SSL::VERIFY_NONE
27:       head = {'Content-Type' => 'application/x-www-form-urlencoded'}
28:       logger.info "-- auth st --" if logger
29:       https.start do |w|
30:         res = w.post(AUTH_PATH, "Email=#{@email}&Passwd=#{CGI.escape(@pass)}&source=company-app-1&service=cl", head)
31:         logger.debug res if logger
32:         if res.body =~ /Auth=(.+)/
33:           @auth = $1 
34:         else
35:           if logger
36:             logger.fatal(res)
37:             logger.fatal(res.body)
38:           end
39:           raise AuthenticationFailed
40:         end
41:       end
42:       logger.info "-- auth en --" if logger
43:     end

[Validate]