omniauth-dailymotion 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ gem 'omniauth-oauth2', :git => 'git://github.com/intridea/omniauth-oauth2.git'
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GIT
2
+ remote: git://github.com/intridea/omniauth-oauth2.git
3
+ revision: 21fd9b0dde4b7afe052bc6a74ce32ca132078188
4
+ specs:
5
+ omniauth-oauth2 (1.0.0)
6
+ oauth2 (~> 0.5.0)
7
+ omniauth (~> 1.0)
8
+
9
+ PATH
10
+ remote: .
11
+ specs:
12
+ omniauth-dailymotion (1.0.0)
13
+ omniauth-oauth2 (~> 1.0.0)
14
+
15
+ GEM
16
+ remote: http://rubygems.org/
17
+ specs:
18
+ addressable (2.2.6)
19
+ diff-lcs (1.1.3)
20
+ faraday (0.7.5)
21
+ addressable (~> 2.2.6)
22
+ multipart-post (~> 1.1.3)
23
+ rack (>= 1.1.0, < 2)
24
+ hashie (1.2.0)
25
+ multi_json (1.0.4)
26
+ multipart-post (1.1.4)
27
+ oauth2 (0.5.2)
28
+ faraday (~> 0.7)
29
+ multi_json (~> 1.0)
30
+ omniauth (1.0.2)
31
+ hashie (~> 1.2)
32
+ rack
33
+ rack (1.4.0)
34
+ rake (0.9.2.2)
35
+ rspec (2.7.0)
36
+ rspec-core (~> 2.7.0)
37
+ rspec-expectations (~> 2.7.0)
38
+ rspec-mocks (~> 2.7.0)
39
+ rspec-core (2.7.1)
40
+ rspec-expectations (2.7.0)
41
+ diff-lcs (~> 1.1.2)
42
+ rspec-mocks (2.7.0)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ omniauth-dailymotion!
49
+ omniauth-oauth2!
50
+ rake
51
+ rspec (~> 2.7.0)
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # OmniAuth Dailymotion
2
+
3
+ This gem contains the Dailymotion strategy for OmniAuth 1.0.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-dailymotion', '~> 1.0.0'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Basic Usage
16
+
17
+ ```ruby
18
+ use OmniAuth::Builder do
19
+ provider :dailymotion, ENV['DAILYMOTION_CLIENT_ID'], ENV['DAILYMOTION_SECRET']
20
+ end
21
+ ```
22
+
23
+ ## Supported Flows
24
+
25
+ Supports the Server-side Flow as described in the the [Dailymotion Data API
26
+ docs](http://www.dailymotion.com/doc/api/authentication.html).
27
+
28
+ ## License
29
+
30
+ Copyright (c) 2012 Nicolas Blanco
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining a
33
+ copy of this software and associated documentation files (the
34
+ "Software"), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included
41
+ in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
44
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1 @@
1
+ require 'omniauth/dailymotion'
@@ -0,0 +1,2 @@
1
+ require 'omniauth/dailymotion/version'
2
+ require 'omniauth/strategies/dailymotion'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Dailymotion
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,65 @@
1
+ require 'omniauth/strategies/oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Dailymotion < OmniAuth::Strategies::OAuth2
6
+ DEFAULT_SCOPE = 'email userinfo'
7
+
8
+ option :name, "dailymotion"
9
+
10
+ option :client_options, {
11
+ :site => 'https://api.dailymotion.com',
12
+ :authorize_url => '/oauth/authorize',
13
+ :token_url => '/oauth/token'
14
+ }
15
+
16
+ uid { raw_info['id'] }
17
+
18
+ info do
19
+ prune!({
20
+ 'screenname' => raw_info['screenname'],
21
+ 'url' => raw_info['url'],
22
+ 'email' => raw_info['email'],
23
+ 'fullname' => raw_info['fullname'],
24
+ 'description' => raw_info['description'],
25
+ 'gender' => raw_info['gender']
26
+ })
27
+ end
28
+
29
+ credentials do
30
+ prune!({
31
+ 'expires' => access_token.expires?,
32
+ 'expires_at' => access_token.expires_at
33
+ })
34
+ end
35
+
36
+ extra do
37
+ prune!({
38
+ 'raw_info' => raw_info
39
+ })
40
+ end
41
+
42
+ def raw_info
43
+ @raw_info ||= access_token.get('/me', :params => { :fields => %w(id,url,email,fullname,description,gender).join(",") }).parsed
44
+ end
45
+
46
+ def authorize_params
47
+ super.tap do |params|
48
+ # params.merge!(:display => request.params['display']) if request.params['display']
49
+ params[:scope] ||= DEFAULT_SCOPE
50
+ end
51
+ end
52
+
53
+ private
54
+
55
+ def prune!(hash)
56
+ hash.delete_if do |_, value|
57
+ prune!(value) if value.is_a?(Hash)
58
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
64
+
65
+ OmniAuth.config.add_camelization 'dailymotion', 'Dailymotion'
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path('../lib', __FILE__)
3
+ require 'omniauth/dailymotion/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'omniauth-dailymotion'
7
+ s.version = OmniAuth::Dailymotion::VERSION
8
+ s.authors = ['Nicolas Blanco']
9
+ s.email = ['nicolas@nicolasblanco.fr']
10
+ s.summary = 'Dailymotion strategy for OmniAuth'
11
+ s.homepage = 'https://github.com/slainer68/omniauth-dailymotion'
12
+
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
16
+ s.require_paths = ['lib']
17
+
18
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
19
+
20
+ s.add_development_dependency 'rspec', '~> 2.7.0'
21
+ s.add_development_dependency 'rake'
22
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-dailymotion'
3
+
4
+ describe OmniAuth::Strategies::Dailymotion do
5
+ subject do
6
+ OmniAuth::Strategies::Dailymotion.new(nil, @options || {})
7
+ end
8
+
9
+ it_should_behave_like 'an oauth2 strategy'
10
+
11
+ describe '#client' do
12
+ it 'should have the correct Dailymotion site' do
13
+ subject.client.site.should eq("https://api.dailymotion.com")
14
+ end
15
+
16
+ it 'should have the correct authorization url' do
17
+ subject.client.options[:authorize_url].should eq("/oauth/authorize")
18
+ end
19
+
20
+ it 'should have the correct token url' do
21
+ subject.client.options[:token_url].should eq('/oauth/token')
22
+ end
23
+ end
24
+
25
+ describe '#callback_path' do
26
+ it 'should have the correct callback path' do
27
+ subject.callback_path.should eq('/auth/dailymotion/callback')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,6 @@
1
+ require 'bundler/setup'
2
+ require 'rspec'
3
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ end
@@ -0,0 +1,37 @@
1
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
2
+ shared_examples 'an oauth2 strategy' do
3
+ describe '#client' do
4
+ it 'should be initialized with symbolized client_options' do
5
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
6
+ subject.client.options[:authorize_url].should == 'https://example.com'
7
+ end
8
+ end
9
+
10
+ describe '#authorize_params' do
11
+ it 'should include any authorize params passed in the :authorize_params option' do
12
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
13
+ subject.authorize_params['foo'].should eq('bar')
14
+ subject.authorize_params['baz'].should eq('zip')
15
+ end
16
+
17
+ it 'should include top-level options that are marked as :authorize_options' do
18
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
19
+ subject.authorize_params['scope'].should eq('bar')
20
+ subject.authorize_params['foo'].should eq('baz')
21
+ end
22
+ end
23
+
24
+ describe '#token_params' do
25
+ it 'should include any authorize params passed in the :authorize_params option' do
26
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
27
+ subject.token_params['foo'].should eq('bar')
28
+ subject.token_params['baz'].should eq('zip')
29
+ end
30
+
31
+ it 'should include top-level options that are marked as :authorize_options' do
32
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
33
+ subject.token_params['scope'].should eq('bar')
34
+ subject.token_params['foo'].should eq('baz')
35
+ end
36
+ end
37
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dailymotion
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Nicolas Blanco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth2
16
+ requirement: &70345294604700 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70345294604700
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70345294429520 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.7.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70345294429520
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70345298297580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70345298297580
47
+ description:
48
+ email:
49
+ - nicolas@nicolasblanco.fr
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - Gemfile
55
+ - Gemfile.lock
56
+ - README.md
57
+ - Rakefile
58
+ - lib/omniauth-dailymotion.rb
59
+ - lib/omniauth/dailymotion.rb
60
+ - lib/omniauth/dailymotion/version.rb
61
+ - lib/omniauth/strategies/dailymotion.rb
62
+ - omniauth-dailymotion.gemspec
63
+ - spec/omniauth/strategies/dailymotion_spec.rb
64
+ - spec/spec_helper.rb
65
+ - spec/support/shared_examples.rb
66
+ homepage: https://github.com/slainer68/omniauth-dailymotion
67
+ licenses: []
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ requirements: []
85
+ rubyforge_project:
86
+ rubygems_version: 1.8.11
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Dailymotion strategy for OmniAuth
90
+ test_files:
91
+ - spec/omniauth/strategies/dailymotion_spec.rb
92
+ - spec/spec_helper.rb
93
+ - spec/support/shared_examples.rb