Class: GmailOAuth::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gmail-oauth/client.rb

Overview

Client.new(“[email protected]”, :access_token => @access_token) Client.new(“[email protected]”, :consumer => @consumer)

Instance Method Summary collapse

Constructor Details

#initialize(email_address, options = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gmail-oauth/client.rb', line 5

def initialize(email_address, options = {})
  raise ArgumentError, "Must provide either an access token (3legged oauth) or a consumer (2legged oauth)" if options[:access_token].nil? && options[:consumer].nil?
  
  @email_address  = email_address
  @access_token   = options[:access_token]
  if @access_token
    @consumer       = @access_token.consumer
  else
    @consumer       = options[:consumer]
  end
  @service        = options[:service] || :imap
end

Instance Method Details

#xoauth_stringObject



18
19
20
21
22
23
# File 'lib/gmail-oauth/client.rb', line 18

def xoauth_string
  params = request["parameters"].merge("oauth_signature" => signature)

  prefix = "GET #{request["uri"]} "
  prefix + params.keys.sort.select { |k| k != "xoauth_requestor_id" }.collect { |k| "#{k}=\"#{CGI.escape(params[k])}\"" }.join(",")
end