omniauth-twitter 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -2,51 +2,53 @@
2
2
 
3
3
  This gem contains the Twitter strategy for OmniAuth.
4
4
 
5
- Twitter uses the OAuth 1.0a flow, you can read about it here: https://dev.twitter.com/docs/auth/oauth
5
+ Twitter offers a few different methods of integration. This strategy implements the browser variant of the "[Sign in with Twitter](https://dev.twitter.com/docs/auth/implementing-sign-twitter)" flow.
6
6
 
7
- ## How To Use It
7
+ Twitter uses OAuth 1.0a. Twitter's developer area contains ample documentation on how it implements this, so if you are really interested in the details, go check that out for more.
8
8
 
9
- Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile`:
9
+ ## Before You Begin
10
10
 
11
- gem 'omniauth-twitter'
11
+ You should have already installed OmniAuth into your app; if not, read the [OmniAuth README](https://github.com/intridea/omniauth) to get started.
12
12
 
13
- You can pull them in directly from github e.g.:
13
+ Now sign in into the [Twitter developer area](http://dev.twitter.com) and create an application. Take note of your Consumer Key and Consumer Secret (not the Access Token and Secret) because that is what your web application will use to authenticate against the Twitter API. Make sure to set a callback URL or else you may get authentication errors. (It doesn't matter what it is, just that it is set.)
14
14
 
15
- gem 'omniauth-twitter', :git => 'https://github.com/arunagw/omniauth-twitter.git'
15
+ ## Using This Strategy
16
16
 
17
- Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
17
+ First start by adding this gem to your Gemfile:
18
18
 
19
- Rails.application.config.middleware.use OmniAuth::Builder do
20
- provider :twitter, "consumer_key", "consumer_secret"
21
- end
19
+ gem 'omniauth-twitter'
22
20
 
23
- You will obviously have to put in your key and secret, which you get when you register your app with Twitter (they call them API Key and Secret Key).
21
+ If you need to use the latest HEAD version, you can do so with:
24
22
 
25
- Twitter also optionally supports specifying a username when authenticating. This is handy when your application supports multiple twitter accounts since you can prompt the user to login to the correct account (and not defaulting to the current login).
23
+ gem 'omniauth-twitter', :github => 'arunagw/omniauth-twitter'
26
24
 
27
- To use this, just add a querystring for screen_name.
25
+ Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
28
26
 
29
- /auth/twitter?screen_name=scottw
27
+ Rails.application.config.middleware.use OmniAuth::Builder do
28
+ provider :twitter, "CONSUMER_KEY", "CONSUMER_SECRET"
29
+ end
30
30
 
31
- You can also specify ```force_login``` without specifying the screen_name to prompt the user to choose the twitter account they wish to use.
31
+ Replace CONSUMER_KEY and CONSUMER_SECRET with the appropriate values you obtained from dev.twitter.com earlier.
32
32
 
33
- /auth/twitter?force_login=true
33
+ ## Authentication Options
34
34
 
35
- Twitter also optionally supports specifying a x_auth_access_type when authenticating. This is handy when you need to specify special permission in some cases.
35
+ Twitter supports a [few options](https://dev.twitter.com/docs/api/1/get/oauth/authenticate) when authenticating. Usually you would specify these options as query parameters to the Twitter API authentication url (`https://api.twitter.com/oauth/authenticate` by default). With OmniAuth, of course, you use `http://yourapp.com/auth/twitter` instead. Because of this, this OmniAuth provider will pick up the query parameters you pass to the `/auth/twitter` URL and re-use them when making the call to the Twitter API.
36
36
 
37
- To use this, just add a querystring for x_auth_access_type.
37
+ The options are:
38
38
 
39
- /auth/twitter?x_auth_access_type=read
39
+ * **force_login** - This option sends the user to a sign-in screen to enter their Twitter credentials, even if they are already signed in. This is handy when your application supports multiple Twitter accounts and you want to ensure the correct user is signed in. *Example:* `http://yoursite.com/auth/twitter?force_login=true`
40
40
 
41
+ * **screen_name** - This option implies **force_login**, except the screen name field is pre-filled with a particular value. *Example:* `http://yoursite.com/auth/twitter?screen_name=jim`
41
42
 
42
- Now just follow the README at: https://github.com/intridea/omniauth
43
+ * **x_auth_access_type** - This option (described [here](https://dev.twitter.com/docs/api/1/post/oauth/request_token)) lets you request the level of access that your app will have to the Twitter account in question. *Example:* `http://yoursite.com/auth/twitter?x_auth_access_type=read`
44
+
45
+ * **use_authorize** - There are actually two URLs you can use against the Twitter API. As mentioned, the default is `https://api.twitter.com/oauth/authenticate`, but you also have `https://api.twitter.com/oauth/authorize`. Passing this option as `true` will use the second URL rather than the first. What's the difference? As described [here](https://dev.twitter.com/docs/api/1/get/oauth/authenticate), with `authenticate`, if your user has already granted permission to your application, Twitter will redirect straight back to your application, whereas `authorize` forces the user to go through the "grant permission" screen again. For certain use cases this may be necessary. *Example:* `http://yoursite.com/auth/twitter?use_authorize=true`
43
46
 
44
47
  ## Watch the RailsCast
45
48
 
46
49
  Ryan Bates has put together an excellent RailsCast on OmniAuth:
47
50
 
48
- [![RailsCast #241](https://www.evernote.com/shard/s35/sh/479f2503-aefa-4542-a7b4-8f84fd22eafc/0571f5a3795a0be3d0b0814312a8d5b7/res/49b5478a-657c-4aff-ae58-dae08b9a46d5/Screen_Shot_2012-07-15_at_12.41.15_PM-20120715-125424.jpg.jpg "RailsCast #241 - Simple OmniAuth (revised)")](http://railscasts.com/episodes/241-simple-omniauth-revised)
49
-
51
+ [![RailsCast #241](https://www.evernote.com/shard/s35/sh/479f2503-aefa-4542-a7b4-8f84fd22eafc/0571f5a3795a0be3d0b0814312a8d5b7/res/49b5478a-657c-4aff-ae58-dae08b9a46d5/Screen_Shot_2012-07-15_at_12.41.15_PM-20120715-125424.jpg "RailsCast #241 - Simple OmniAuth (revised)")](http://railscasts.com/episodes/241-simple-omniauth-revised)
50
52
 
51
53
  ## Supported Rubies
52
54
 
@@ -71,4 +73,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
71
73
 
72
74
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
73
75
 
74
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
76
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,2 +1,2 @@
1
1
  require "omniauth-twitter/version"
2
- require 'omniauth/strategies/twitter'
2
+ require 'omniauth/strategies/twitter'
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Twitter
3
- VERSION = "0.0.13"
3
+ VERSION = "0.0.14"
4
4
  end
5
5
  end
@@ -30,7 +30,7 @@ module OmniAuth
30
30
  end
31
31
 
32
32
  def raw_info
33
- @raw_info ||= MultiJson.load(access_token.get('/1/account/verify_credentials.json').body)
33
+ @raw_info ||= MultiJson.load(access_token.get('/1.1/account/verify_credentials.json').body)
34
34
  rescue ::Errno::ETIMEDOUT
35
35
  raise ::Timeout::Error
36
36
  end
@@ -59,7 +59,7 @@ module OmniAuth
59
59
  else
60
60
  options.client_options.authorize_path = '/oauth/authenticate'
61
61
  end
62
-
62
+
63
63
  old_request_phase
64
64
  end
65
65
 
@@ -23,5 +23,5 @@ Gem::Specification.new do |s|
23
23
  s.add_development_dependency 'rspec', '~> 2.7'
24
24
  s.add_development_dependency 'rack-test'
25
25
  s.add_development_dependency 'simplecov'
26
- s.add_development_dependency 'webmock'
26
+ s.add_development_dependency 'webmock'
27
27
  end
@@ -5,17 +5,17 @@ describe OmniAuth::Strategies::Twitter do
5
5
  OmniAuth::Strategies::Twitter.new({})
6
6
  end
7
7
 
8
- context "client options" do
8
+ context 'client options' do
9
9
  it 'should have correct name' do
10
- subject.options.name.should eq("twitter")
10
+ expect(subject.options.name).to eq('twitter')
11
11
  end
12
12
 
13
13
  it 'should have correct site' do
14
- subject.options.client_options.site.should eq('https://api.twitter.com')
14
+ expect(subject.options.client_options.site).to eq('https://api.twitter.com')
15
15
  end
16
16
 
17
17
  it 'should have correct authorize url' do
18
- subject.options.client_options.authorize_path.should eq('/oauth/authenticate')
18
+ expect(subject.options.client_options.authorize_path).to eq('/oauth/authenticate')
19
19
  end
20
20
  end
21
21
  end
data/spec/spec_helper.rb CHANGED
@@ -12,5 +12,7 @@ RSpec.configure do |config|
12
12
  config.include WebMock::API
13
13
  config.include Rack::Test::Methods
14
14
  config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ config.expect_with :rspec do |c|
16
+ c.syntax = :expect
17
+ end
15
18
  end
16
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-twitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-04 00:00:00.000000000 Z
12
+ date: 2012-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: 1976515917874088627
143
+ hash: -2549198419643775481
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  segments:
151
151
  - 0
152
- hash: 1976515917874088627
152
+ hash: -2549198419643775481
153
153
  requirements: []
154
154
  rubyforge_project: omniauth-twitter
155
155
  rubygems_version: 1.8.24