Class: GoogleOAuth::Consumer
- Inherits:
-
OAuth::Consumer
- Object
- OAuth::Consumer
- GoogleOAuth::Consumer
- Defined in:
- lib/contacts/google_oauth.rb
Instance Method Summary collapse
- #get_request_token(params = {}) ⇒ Object
-
#initialize(consumer_key, consumer_secret) ⇒ Consumer
constructor
A new instance of Consumer.
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
Constructor Details
#initialize(consumer_key, consumer_secret) ⇒ Consumer
Returns a new instance of Consumer.
15 16 17 18 19 20 21 22 |
# File 'lib/contacts/google_oauth.rb', line 15 def initialize(consumer_key, consumer_secret) super(consumer_key, consumer_secret, {:site => "https://www.google.com", :request_token_path => "/accounts/OAuthGetRequestToken", :access_token_path => "/accounts/OAuthGetAccessToken", :authorize_path => "/accounts/OAuthAuthorizeToken"}) end |
Instance Method Details
#get_request_token(params = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/contacts/google_oauth.rb', line 32 def get_request_token(params={}) params_str = params.map { |k,v| "%s=%s" % [CGI.escape(k.to_s), CGI.escape(v)] }.join("&") uri = URI.parse(request_token_url? ? request_token_url : request_token_path) if !uri.query || uri.query == '' uri.query = params_str else uri.query = uri.query + "&" + params_str end response=token_request(http_method, uri.to_s, nil, {}) GoogleOAuth::RequestToken.new(self, response[:oauth_token], response[:oauth_token_secret]) end |
#marshal_dump ⇒ Object
28 29 30 |
# File 'lib/contacts/google_oauth.rb', line 28 def marshal_dump {:key => self.key, :secret => self.secret} end |
#marshal_load(data) ⇒ Object
24 25 26 |
# File 'lib/contacts/google_oauth.rb', line 24 def marshal_load(data) initialize(data[:key], data[:secret]) end |