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 +25 -23
- data/lib/omniauth-twitter.rb +1 -1
- data/lib/omniauth-twitter/version.rb +1 -1
- data/lib/omniauth/strategies/twitter.rb +2 -2
- data/omniauth-twitter.gemspec +1 -1
- data/spec/omniauth/strategies/twitter_spec.rb +4 -4
- data/spec/spec_helper.rb +3 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -2,51 +2,53 @@
|
|
2
2
|
|
3
3
|
This gem contains the Twitter strategy for OmniAuth.
|
4
4
|
|
5
|
-
Twitter
|
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
|
-
|
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
|
-
|
9
|
+
## Before You Begin
|
10
10
|
|
11
|
-
|
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
|
-
|
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
|
-
|
15
|
+
## Using This Strategy
|
16
16
|
|
17
|
-
|
17
|
+
First start by adding this gem to your Gemfile:
|
18
18
|
|
19
|
-
|
20
|
-
provider :twitter, "consumer_key", "consumer_secret"
|
21
|
-
end
|
19
|
+
gem 'omniauth-twitter'
|
22
20
|
|
23
|
-
|
21
|
+
If you need to use the latest HEAD version, you can do so with:
|
24
22
|
|
25
|
-
|
23
|
+
gem 'omniauth-twitter', :github => 'arunagw/omniauth-twitter'
|
26
24
|
|
27
|
-
|
25
|
+
Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
|
28
26
|
|
29
|
-
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :twitter, "CONSUMER_KEY", "CONSUMER_SECRET"
|
29
|
+
end
|
30
30
|
|
31
|
-
|
31
|
+
Replace CONSUMER_KEY and CONSUMER_SECRET with the appropriate values you obtained from dev.twitter.com earlier.
|
32
32
|
|
33
|
-
|
33
|
+
## Authentication Options
|
34
34
|
|
35
|
-
Twitter
|
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
|
-
|
37
|
+
The options are:
|
38
38
|
|
39
|
-
|
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
|
-
|
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
|
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.
|
data/lib/omniauth-twitter.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require "omniauth-twitter/version"
|
2
|
-
require 'omniauth/strategies/twitter'
|
2
|
+
require 'omniauth/strategies/twitter'
|
@@ -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
|
|
data/omniauth-twitter.gemspec
CHANGED
@@ -5,17 +5,17 @@ describe OmniAuth::Strategies::Twitter do
|
|
5
5
|
OmniAuth::Strategies::Twitter.new({})
|
6
6
|
end
|
7
7
|
|
8
|
-
context
|
8
|
+
context 'client options' do
|
9
9
|
it 'should have correct name' do
|
10
|
-
subject.options.name.
|
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.
|
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.
|
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
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.
|
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-
|
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:
|
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:
|
152
|
+
hash: -2549198419643775481
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project: omniauth-twitter
|
155
155
|
rubygems_version: 1.8.24
|