Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for custom OAuth paths. Closes GH-3

  • Loading branch information...
commit f5accd5037acf2439438c37fbb0dc7c9f3c1edbb 1 parent 1fe312e
@mbleigh authored
View
5 generators/twitter_auth/templates/twitter_auth.yml
@@ -4,6 +4,7 @@ development:
oauth_consumer_key: devkey
oauth_consumer_secret: devsecret
base_url: "https://twitter.com"
+ authorize_path: "/oauth/authenticate"
api_timeout: 10
remember_for: 14 # days
oauth_callback: "http://localhost:3000/oauth_callback"
@@ -12,13 +13,15 @@ test:
oauth_consumer_key: testkey
oauth_consumer_secret: testsecret
base_url: "https://twitter.com"
+ authorize_path: "/oauth/authenticate"
api_timeout: 10
remember_for: 14 # days
oauth_callback: "http://localhost:3000/oauth_callback"
production:
strategy: oauth
oauth_consumer_key: prodkey
- oauth_consumer_secret: prodsecret
+ oauth_consumer_secret: prodsecret
+ authorize_path: "/oauth/authenticate"
base_url: "https://twitter.com"
api_timeout: 10
remember_for: 14 # days
View
14 lib/twitter_auth.rb
@@ -56,10 +56,18 @@ def self.basic?
# The OAuth consumer used by TwitterAuth for authentication. The consumer key and secret are set in your application's +config/twitter.yml+
def self.consumer
+ options = {:site => TwitterAuth.base_url}
+ [ :authorize_path,
+ :request_token_path,
+ :access_token_path,
+ :scheme ].each do |oauth_option|
+ options[oauth_option] = TwitterAuth.config[oauth_option.to_s] if TwitterAuth.config[oauth_option.to_s]
+ end
+
OAuth::Consumer.new(
config['oauth_consumer_key'],
config['oauth_consumer_secret'],
- :site => TwitterAuth.base_url
+ options
)
end
@@ -70,6 +78,10 @@ def self.net
net.read_timeout = TwitterAuth.api_timeout
net
end
+
+ def self.authorize_path
+ config['authorize_path'] || '/oauth/authorize'
+ end
end
require 'twitter_auth/controller_extensions'
View
6 spec/twitter_auth_spec.rb
@@ -11,6 +11,12 @@
TwitterAuth.stub!(:config).and_return({'base_url' => 'https://example.com'})
TwitterAuth.base_url.should == 'https://example.com'
end
+
+ it 'should utilize oauth consumer settings' do
+ @config = TwitterAuth.config
+ TwitterAuth.stub!(:config).and_return(@config.merge('authorize_path' => '/somewhere_else'))
+ TwitterAuth.consumer.authorize_path.should == '/somewhere_else'
+ end
end
describe ".path_prefix" do
Please sign in to comment.
Something went wrong with that request. Please try again.