Package list ruby-omniauth-twitter / 2661436
Merge tag 'upstream/1.2.0' Upstream version 1.2.0 # gpg: Signature made Wednesday 15 July 2015 06:43:24 PM IST using RSA key ID 4512C22A # gpg: Good signature from "Praveen Arimbrathodiyil (piratepin) <praveen@debian.org>" # gpg: aka "Pirate Praveen (pirates.org.in) <praveen@onenetbeyond.org>" # gpg: aka "Pirate Praveen (piratesin) <me@j4v4m4n.in>" # gpg: aka "Pirate Praveen (PP) <praveen@privacyrequired.com>" # gpg: aka "Praveen Arimbrathodiyil (j4v4m4n) <pravi.a@gmail.com>" Praveen Arimbrathodiyil 6 years ago
11 changed file(s) with 142 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
00 rvm:
1 - 1.8.7
2 - 1.9.2
31 - 1.9.3
4 - ree
2 - 2.0.0
3 - 2.1
4 - 2.2
55 - jruby
6 - rbx-2
0 # Contributing
1
2 For the best chance of having your changes merged, please:
3
4 * Fork the project.
5
6 * Make your feature addition or bug fix.
7
8 * Add tests for it. This is important so it is not accidentally broken in a future version.
9
10 * Commit, do not mess with rakefile, version, or history. (If you want to have your own version, that is fine but bump version in a commit by itself so it can be ignored when pulled).
11
12 * Send a pull request. Bonus points for topic branches.
13
14 If your proposed changes only affect documentation, include the following on a
15 new line in each of your commit messages:
16
17 ```
18 [ci skip]
19 ```
20
21 This will signal [Travis](https://travis-ci.org) that running the test suite is
22 not necessary for these changes.
23
24 # Reporting Bugs
25
26 If you are experiencing unexpected behavior and, after having read [omniauth](https://github.com/intridea/omniauth) and [omniauth-twitter](https://github.com/arunagw/omniauth-twitter)'s documentation, are convinced this behavior is a bug, please:
27
28 1. [Search](https://github.com/arunagw/omniauth-twitter/issues) existing issues.
29 2. Collect enough information to reproduce the issue:
30
31 * omniauth-twitter version
32
33 * Ruby version
34
35 * Specific setup conditions
36
37 * Description of expected behavior
38
39 * Description of actual behavior
0 source "https://rubygems.org"
0 source 'https://rubygems.org'
1
2 gemspec
13
24 gem 'rake'
3 # Specify your gem's dependencies in omniauth-twitter.gemspec
4 gemspec
5
6 group :test do
7 gem 'rspec', '~> 3.2'
8 gem 'rack-test'
9 gem 'simplecov'
10 gem 'webmock'
11 end
00 # OmniAuth Twitter
1
2 [![Gem Version](https://badge.fury.io/rb/omniauth-twitter.svg)](http://badge.fury.io/rb/omniauth-twitter)
3 [![CI Build Status](https://secure.travis-ci.org/arunagw/omniauth-twitter.svg?branch=master)](http://travis-ci.org/arunagw/omniauth-twitter)
4 [![Code Climate](https://codeclimate.com/github/arunagw/omniauth-twitter.png)](https://codeclimate.com/github/arunagw/omniauth-twitter)
15
26 This gem contains the Twitter strategy for OmniAuth.
37
48 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.
59
6 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.
10 Twitter uses OAuth 1.0a. Twitter's developer area contains ample documentation on how it implements this, so check that out if you are really interested in the details.
711
812 ## Before You Begin
913
1014 You should have already installed OmniAuth into your app; if not, read the [OmniAuth README](https://github.com/intridea/omniauth) to get started.
1115
12 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.)
16 Now sign in into the [Twitter developer area](https://dev.twitter.com/apps) and create an application. Take note of your API Key and API Secret (not the Access Token and Access Token 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.)
1317
1418 ## Using This Strategy
1519
2933
3034 ```ruby
3135 Rails.application.config.middleware.use OmniAuth::Builder do
32 provider :twitter, "CONSUMER_KEY", "CONSUMER_SECRET"
36 provider :twitter, "API_KEY", "API_SECRET"
3337 end
3438 ```
3539
36 Replace CONSUMER_KEY and CONSUMER_SECRET with the appropriate values you obtained from dev.twitter.com earlier.
40 Replace `"API_KEY"` and `"API_SECRET"` with the appropriate values you obtained [earlier](https://apps.twitter.com).
3741
3842 ## Authentication Options
3943
5963
6064 ```ruby
6165 Rails.application.config.middleware.use OmniAuth::Builder do
62 provider :twitter, ENV["TWITTER_KEY"], ENV["TWITTER_SECRET"],
66 provider :twitter, "API_KEY", "API_SECRET",
6367 {
6468 :secure_image_url => 'true',
6569 :image_size => 'original',
97101 :access_token => "", # An OAuth::AccessToken object
98102 :raw_info => {
99103 :name => "John Q Public",
100 :listed_count" => 0,
101 :profile_sidebar_border_color" => "181A1E",
104 :listed_count => 0,
105 :profile_sidebar_border_color => "181A1E",
102106 :url => nil,
103107 :lang => "en",
104108 :statuses_count => 129,
151155
152156 ## Supported Rubies
153157
154 OmniAuth Twitter is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
158 OmniAuth Twitter is tested under 1.9.3, 2.0.0, 2.1.x, 2.2.x, JRuby, and Rubinius.
155159
156 [![CI Build
157 Status](https://secure.travis-ci.org/arunagw/omniauth-twitter.png)](http://travis-ci.org/arunagw/omniauth-twitter)
160 ## Contributing
158161
159 ## Note on Patches/Pull Requests
160
161 - Fork the project.
162 - Make your feature addition or bug fix.
163 - Add tests for it. This is important so I don’t break it in a future version unintentionally.
164 - Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
165 - Send me a pull request. Bonus points for topic branches.
162 Please read the [contribution guidelines](CONTRIBUTING.md) for some information on how to get started. No contribution is too small.
166163
167164 ## License
168165
checksums.yaml.gz less more
Binary diff not shown
00 require 'omniauth-oauth'
1 require 'multi_json'
1 require 'json'
22
33 module OmniAuth
44 module Strategies
2626 end
2727
2828 extra do
29 { :raw_info => raw_info }
29 skip_info? ? {} : { :raw_info => raw_info }
3030 end
3131
3232 def raw_info
33 @raw_info ||= MultiJson.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true').body)
33 @raw_info ||= JSON.load(access_token.get('/1.1/account/verify_credentials.json?include_entities=false&skip_status=true').body)
3434 rescue ::Errno::ETIMEDOUT
3535 raise ::Timeout::Error
3636 end
5050 end
5151 end
5252
53 if request.params['use_authorize'] == 'true'
53 if options[:use_authorize] || request.params['use_authorize'] == 'true'
5454 options[:client_options][:authorize_path] = '/oauth/authorize'
5555 else
5656 options[:client_options][:authorize_path] = '/oauth/authenticate'
00 module OmniAuth
11 module Twitter
2 VERSION = "1.0.1"
2 VERSION = "1.2.0"
33 end
44 end
00 --- !ruby/object:Gem::Specification
11 name: omniauth-twitter
22 version: !ruby/object:Gem::Version
3 version: 1.0.1
3 version: 1.2.0
44 platform: ruby
55 authors:
66 - Arun Agrawal
77 autorequire:
88 bindir: bin
99 cert_chain: []
10 date: 2013-10-04 00:00:00.000000000 Z
10 date: 2015-04-22 00:00:00.000000000 Z
1111 dependencies:
1212 - !ruby/object:Gem::Dependency
13 name: multi_json
13 name: json
1414 requirement: !ruby/object:Gem::Requirement
1515 requirements:
1616 - - ~>
2929 requirements:
3030 - - ~>
3131 - !ruby/object:Gem::Version
32 version: '1.0'
32 version: '1.1'
3333 type: :runtime
3434 prerelease: false
3535 version_requirements: !ruby/object:Gem::Requirement
3636 requirements:
3737 - - ~>
3838 - !ruby/object:Gem::Version
39 version: '1.0'
39 version: '1.1'
4040 - !ruby/object:Gem::Dependency
41 name: rspec
41 name: bundler
4242 requirement: !ruby/object:Gem::Requirement
4343 requirements:
4444 - - ~>
4545 - !ruby/object:Gem::Version
46 version: '2.7'
46 version: '1.0'
4747 type: :development
4848 prerelease: false
4949 version_requirements: !ruby/object:Gem::Requirement
5050 requirements:
5151 - - ~>
5252 - !ruby/object:Gem::Version
53 version: '2.7'
54 - !ruby/object:Gem::Dependency
55 name: rack-test
56 requirement: !ruby/object:Gem::Requirement
57 requirements:
58 - - '>='
59 - !ruby/object:Gem::Version
60 version: '0'
61 type: :development
62 prerelease: false
63 version_requirements: !ruby/object:Gem::Requirement
64 requirements:
65 - - '>='
66 - !ruby/object:Gem::Version
67 version: '0'
68 - !ruby/object:Gem::Dependency
69 name: simplecov
70 requirement: !ruby/object:Gem::Requirement
71 requirements:
72 - - '>='
73 - !ruby/object:Gem::Version
74 version: '0'
75 type: :development
76 prerelease: false
77 version_requirements: !ruby/object:Gem::Requirement
78 requirements:
79 - - '>='
80 - !ruby/object:Gem::Version
81 version: '0'
82 - !ruby/object:Gem::Dependency
83 name: webmock
84 requirement: !ruby/object:Gem::Requirement
85 requirements:
86 - - '>='
87 - !ruby/object:Gem::Version
88 version: '0'
89 type: :development
90 prerelease: false
91 version_requirements: !ruby/object:Gem::Requirement
92 requirements:
93 - - '>='
94 - !ruby/object:Gem::Version
95 version: '0'
53 version: '1.0'
9654 description: OmniAuth strategy for Twitter
9755 email:
9856 - arunagw@gmail.com
10361 - .gitignore
10462 - .rspec
10563 - .travis.yml
64 - CONTRIBUTING.md
10665 - Gemfile
10766 - README.md
10867 - Rakefile
13190 - !ruby/object:Gem::Version
13291 version: '0'
13392 requirements: []
134 rubyforge_project: omniauth-twitter
135 rubygems_version: 2.0.6
93 rubyforge_project:
94 rubygems_version: 2.0.14
13695 signing_key:
13796 specification_version: 4
13897 summary: OmniAuth strategy for Twitter
77 s.authors = ["Arun Agrawal"]
88 s.email = ["arunagw@gmail.com"]
99 s.homepage = "https://github.com/arunagw/omniauth-twitter"
10 s.summary = %q{OmniAuth strategy for Twitter}
1110 s.description = %q{OmniAuth strategy for Twitter}
11 s.summary = s.description
1212 s.license = "MIT"
13
14 s.rubyforge_project = "omniauth-twitter"
1513
1614 s.files = `git ls-files`.split("\n")
1715 s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
1816 s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
1917 s.require_paths = ["lib"]
2018
21 s.add_dependency 'multi_json', '~> 1.3'
22 s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
23 s.add_development_dependency 'rspec', '~> 2.7'
24 s.add_development_dependency 'rack-test'
25 s.add_development_dependency 'simplecov'
26 s.add_development_dependency 'webmock'
19 s.add_dependency 'json', '~> 1.3'
20 s.add_dependency 'omniauth-oauth', '~> 1.1'
21 s.add_development_dependency 'bundler', '~> 1.0'
2722 end
55 subject do
66 args = ['appid', 'secret', @options || {}].compact
77 OmniAuth::Strategies::Twitter.new(*args).tap do |strategy|
8 strategy.stub(:request) {
8 allow(strategy).to receive(:request) {
99 request
1010 }
1111 end
2929 context 'when user has an image' do
3030 it 'should return image with size specified' do
3131 @options = { :image_size => 'original' }
32 subject.stub(:raw_info).and_return(
32 allow(subject).to receive(:raw_info).and_return(
3333 { 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
3434 )
3535 expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0.png')
3636 end
3737
38 it 'should return bigger image when bigger size specified' do
39 @options = { :image_size => 'bigger' }
40 allow(subject).to receive(:raw_info).and_return(
41 { 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
42 )
43 expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_bigger.png')
44 end
45
3846 it 'should return secure image with size specified' do
3947 @options = { :secure_image_url => 'true', :image_size => 'mini' }
40 subject.stub(:raw_info).and_return(
48 allow(subject).to receive(:raw_info).and_return(
4149 { 'profile_image_url_https' => 'https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
4250 )
4351 expect(subject.info[:image]).to eq('https://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_mini.png')
4452 end
4553
4654 it 'should return normal image by default' do
47 subject.stub(:raw_info).and_return(
55 allow(subject).to receive(:raw_info).and_return(
4856 { 'profile_image_url' => 'http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png' }
4957 )
5058 expect(subject.info[:image]).to eq('http://twimg0-a.akamaihd.net/sticky/default_profile_images/default_profile_0_normal.png')
5260 end
5361 end
5462
63 describe 'skip_info option' do
64 context 'when skip info option is enabled' do
65 it 'should not include raw_info in extras hash' do
66 @options = { :skip_info => true }
67 allow(subject).to receive(:raw_info).and_return({:foo => 'bar'})
68 expect(subject.extra[:raw_info]).to eq(nil)
69 end
70 end
71 end
72
5573 describe 'request_phase' do
5674 context 'with no request params set and x_auth_access_type specified' do
5775 before do
58 subject.stub(:request).and_return(
76 allow(subject).to receive(:request).and_return(
5977 double('Request', {:params => {'x_auth_access_type' => 'read'}})
6078 )
61 subject.stub(:old_request_phase).and_return(:whatever)
79 allow(subject).to receive(:old_request_phase).and_return(:whatever)
6280 end
6381
6482 it 'should not break' do
6583 expect { subject.request_phase }.not_to raise_error
6684 end
6785 end
86
87 context "with no request params set and use_authorize options provided" do
88 before do
89 @options = { :use_authorize => true }
90 allow(subject).to receive(:request) do
91 double('Request', {:params => {} })
92 end
93 allow(subject).to receive(:old_request_phase) { :whatever }
94 end
95
96 it "should switch authorize_path from authenticate to authorize" do
97 expect { subject.request_phase }.to change { subject.options.client_options.authorize_path }.from('/oauth/authenticate').to('/oauth/authorize')
98 end
99 end
100
101 context "with no request params set and force_login specified" do
102 before do
103 allow(subject).to receive(:request) do
104 double('Request', {:params => { 'force_login' => true } })
105 end
106 allow(subject).to receive(:old_request_phase) { :whatever }
107 end
108
109 it "should change add force_login=true to authorize_params" do
110 expect { subject.request_phase }.to change {subject.options.authorize_params.force_login}.from(nil).to(true)
111 end
112 end
68113 end
69114 end
00 $:.unshift File.expand_path('..', __FILE__)
11 $:.unshift File.expand_path('../../lib', __FILE__)
22 require 'simplecov'
3 SimpleCov.start
3 SimpleCov.start do
4 minimum_coverage(94.59)
5 end
46 require 'rspec'
57 require 'rack/test'
68 require 'webmock/rspec'