Class: GoogleSpreadsheets::Connection
- Inherits:
-
ActiveResource::Connection
- Object
- ActiveResource::Connection
- GoogleSpreadsheets::Connection
- Defined in:
- lib/google_spreadsheets/connection.rb
Instance Method Summary collapse
- #access_token ⇒ Object
- #authorization_header(http_method, uri) ⇒ Object
-
#client_login_authorization_header(http_method, uri) ⇒ Object
Deprecated and Not recommended.
Instance Method Details
#access_token ⇒ Object
11 12 13 |
# File 'lib/google_spreadsheets/connection.rb', line 11 def access_token @password.respond_to?(:call) ? @password.call(self) : @password end |
#authorization_header(http_method, uri) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/google_spreadsheets/connection.rb', line 3 def (http_method, uri) if auth_type == :bearer { 'Authorization' => "Bearer #{access_token}" } else (http_method, uri) end end |
#client_login_authorization_header(http_method, uri) ⇒ Object
Deprecated and Not recommended
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/google_spreadsheets/connection.rb', line 16 def (http_method, uri) if @user && @password && !@auth_token email = CGI.escape(@user) password = CGI.escape(@password) http = Net::HTTP.new('www.google.com', 443) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE resp, data = http.post('/accounts/ClientLogin', "accountType=HOSTED_OR_GOOGLE&Email=#{email}&Passwd=#{password}&service=wise", { 'Content-Type' => 'application/x-www-form-urlencoded' }) handle_response(resp) @auth_token = (data || resp.body)[/Auth=(.*)/n, 1] end @auth_token ? { 'Authorization' => "GoogleLogin auth=#{@auth_token}" } : {} end |