evently-omniauth-eventbrite 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +6 -0
- data/README.md +46 -0
- data/Rakefile +6 -0
- data/lib/omniauth-eventbrite.rb +1 -0
- data/lib/omniauth/eventbrite.rb +2 -0
- data/lib/omniauth/eventbrite/version.rb +5 -0
- data/lib/omniauth/strategies/eventbrite.rb +78 -0
- data/omniauth-eventbrite.gemspec +24 -0
- data/spec/omniauth/strategies/eventbrite_spec.rb +30 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/shared_examples.rb +37 -0
- metadata +109 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# OmniAuth Eventbrite
|
2
|
+
|
3
|
+
This gem contains the Eventbrite strategy for OmniAuth 1.0.
|
4
|
+
|
5
|
+
## Installing
|
6
|
+
|
7
|
+
Add to your `Gemfile`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'omniauth-eventbrite', '~> 0.0.3'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then `bundle install`.
|
14
|
+
|
15
|
+
## Basic Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
use OmniAuth::Builder do
|
19
|
+
provider :eventbrite, ENV['EVENTBRITE_CLIENT_ID'], ENV['EVENTBRITE_CLIENT_SECRET']
|
20
|
+
end
|
21
|
+
```
|
22
|
+
|
23
|
+
You can find your client secret on the same page where your application API key is.
|
24
|
+
|
25
|
+
## License
|
26
|
+
|
27
|
+
Copyright (c) 2012 Kruttik Aggarwal
|
28
|
+
|
29
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
30
|
+
copy of this software and associated documentation files (the
|
31
|
+
"Software"), to deal in the Software without restriction, including
|
32
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
33
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
34
|
+
permit persons to whom the Software is furnished to do so, subject to
|
35
|
+
the following conditions:
|
36
|
+
|
37
|
+
The above copyright notice and this permission notice shall be included
|
38
|
+
in all copies or substantial portions of the Software.
|
39
|
+
|
40
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
41
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
42
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
43
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
44
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
45
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
46
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/eventbrite"
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'omniauth/strategies/oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Eventbrite < OmniAuth::Strategies::OAuth2
|
6
|
+
DEFAULT_RESPONSE_TYPE = 'code'
|
7
|
+
DEFAULT_GRANT = 'authorization_code'
|
8
|
+
|
9
|
+
option :name, "eventbrite"
|
10
|
+
|
11
|
+
option :client_options, {
|
12
|
+
:site => "https://www.eventbrite.com",
|
13
|
+
:authorize_url => '/oauth/authorize',
|
14
|
+
:token_url => '/oauth/token'
|
15
|
+
}
|
16
|
+
uid { raw_info['user_id'].to_s }
|
17
|
+
|
18
|
+
def request_phase
|
19
|
+
options[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
20
|
+
options[:client_id] = client.id
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize_params
|
25
|
+
super.tap do |params|
|
26
|
+
params[:response_type] ||= DEFAULT_RESPONSE_TYPE
|
27
|
+
params[:client_id] = client.id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def token_params
|
32
|
+
super.tap do |params|
|
33
|
+
params[:grant_type] ||= DEFAULT_GRANT
|
34
|
+
params[:client_id] = client.id
|
35
|
+
params[:client_secret] = client.secret
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
info do
|
40
|
+
prune!({
|
41
|
+
'email' => raw_info['email'],
|
42
|
+
'name' => construct_full_name(raw_info['first_name'], raw_info['last_name']),
|
43
|
+
'first_name' => raw_info['first_name'],
|
44
|
+
'last_name' => raw_info['last_name'],
|
45
|
+
})
|
46
|
+
end
|
47
|
+
|
48
|
+
extra do
|
49
|
+
prune!({
|
50
|
+
'raw_info' => raw_info
|
51
|
+
})
|
52
|
+
end
|
53
|
+
|
54
|
+
def raw_info
|
55
|
+
@raw_info ||= access_token.get('/json/user_get').parsed['user']
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def construct_full_name(first_name, last_name)
|
61
|
+
if first_name and last_name
|
62
|
+
"#{first_name} #{last_name}"
|
63
|
+
else
|
64
|
+
first_name || last_name || nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def prune!(hash)
|
69
|
+
hash.delete_if do |_, value|
|
70
|
+
prune!(value) if value.is_a?(Hash)
|
71
|
+
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
OmniAuth.config.add_camelization 'eventbrite', 'Eventbrite'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'omniauth/eventbrite/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'evently-omniauth-eventbrite'
|
7
|
+
s.version = Omniauth::Eventbrite::VERSION
|
8
|
+
s.authors = ['Kruttik Aggarwal']
|
9
|
+
s.email = ['kruttikagarwal@gmail.com']
|
10
|
+
s.homepage = 'https://github.com/evently/omniauth-eventbrite'
|
11
|
+
s.summary = 'Eventbrite strategy for Omniauth with OAuth 2.0'
|
12
|
+
s.description = 'Eventbrite strategy for OmniAuth'
|
13
|
+
|
14
|
+
s.rubyforge_project = 'evently-omniauth-eventbrite'
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
|
21
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.1'
|
22
|
+
s.add_development_dependency 'rspec', '~> 2.7.0'
|
23
|
+
s.add_development_dependency 'rake'
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'omniauth-eventbrite'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Eventbrite do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::Eventbrite.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 Eventbrite site' do
|
13
|
+
subject.client.site.should eq("https://www.eventbrite.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/eventbrite/callback')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -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,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evently-omniauth-eventbrite
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kruttik Aggarwal
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth2
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.1
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 2.7.0
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 2.7.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: Eventbrite strategy for OmniAuth
|
63
|
+
email:
|
64
|
+
- kruttikagarwal@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/omniauth-eventbrite.rb
|
74
|
+
- lib/omniauth/eventbrite.rb
|
75
|
+
- lib/omniauth/eventbrite/version.rb
|
76
|
+
- lib/omniauth/strategies/eventbrite.rb
|
77
|
+
- omniauth-eventbrite.gemspec
|
78
|
+
- spec/omniauth/strategies/eventbrite_spec.rb
|
79
|
+
- spec/spec_helper.rb
|
80
|
+
- spec/support/shared_examples.rb
|
81
|
+
homepage: https://github.com/evently/omniauth-eventbrite
|
82
|
+
licenses: []
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
requirements: []
|
100
|
+
rubyforge_project: evently-omniauth-eventbrite
|
101
|
+
rubygems_version: 1.8.23
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Eventbrite strategy for Omniauth with OAuth 2.0
|
105
|
+
test_files:
|
106
|
+
- spec/omniauth/strategies/eventbrite_spec.rb
|
107
|
+
- spec/spec_helper.rb
|
108
|
+
- spec/support/shared_examples.rb
|
109
|
+
has_rdoc:
|