lib/authlogic_connect/oauth/tokens/oauth_token.rb in authlogic-connect-0.0.4.05 vs lib/authlogic_connect/oauth/tokens/oauth_token.rb in authlogic-connect-0.0.4.06
- old
+ new
@@ -15,13 +15,17 @@
def oauth_version
self.class.oauth_version
end
def get(path, options = {})
- client.get(path)
+ client.get(path, options)
end
-
+
+ def post(path, body='', headers ={})
+ client.post(path, body, headers)
+ end
+
class << self
# oauth version, 1.0 or 2.0
def version(value)
@oauth_version = value
@@ -50,11 +54,11 @@
def consumer
unless @consumer
if oauth_version == 1.0
@consumer = OAuth::Consumer.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {}))
else
- @consumer = OAuth2::Client.new(credentials[:key], credentials[:secret], config)
+ @consumer = OAuth2::Client.new(credentials[:key], credentials[:secret], config.merge(credentials[:options] || {}))
end
end
@consumer
end
@@ -109,10 +113,15 @@
request = get_request_token(callback_url)
yield request if block_given?
return request.authorize_url
else
options = {:redirect_uri => callback_url}
- options[:scope] = self.config[:scope] unless self.config[:scope].blank?
+
+ unless consumer.nil? || consumer.options.empty? || consumer.options[:scope].nil?
+ options[:scope] = consumer.options[:scope]
+ else
+ options[:scope] = self.config[:scope] unless self.config[:scope].blank?
+ end
return consumer.web_server.authorize_url(options)
end
end
def request_token(token, secret)