omniauth-mailchimp 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ omniauth-mailchimp-1.0.gem
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :example do
6
+ gem 'sinatra'
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-mailchimp (1.0)
5
+ omniauth (~> 1.0)
6
+ omniauth-oauth2
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activesupport (3.1.1)
12
+ multi_json (~> 1.0)
13
+ addressable (2.2.6)
14
+ diff-lcs (1.1.3)
15
+ faraday (0.7.5)
16
+ addressable (~> 2.2.6)
17
+ multipart-post (~> 1.1.3)
18
+ rack (>= 1.1.0, < 2)
19
+ gibbon (0.3.1)
20
+ activesupport (>= 2.3.14)
21
+ activesupport (>= 2.3.14)
22
+ httparty (> 0.6.0)
23
+ httparty (> 0.6.0)
24
+ json (> 1.4.0)
25
+ json (> 1.4.0)
26
+ rdoc
27
+ hashie (1.2.0)
28
+ httparty (0.8.1)
29
+ multi_json
30
+ multi_xml
31
+ json (1.6.1)
32
+ multi_json (1.0.4)
33
+ multi_xml (0.3.0)
34
+ multipart-post (1.1.4)
35
+ oauth2 (0.5.1)
36
+ faraday (~> 0.7.4)
37
+ multi_json (~> 1.0.3)
38
+ omniauth (1.0.1)
39
+ hashie (~> 1.2)
40
+ rack
41
+ omniauth-oauth2 (1.0.0)
42
+ oauth2 (~> 0.5.0)
43
+ omniauth (~> 1.0)
44
+ rack (1.3.5)
45
+ rack-protection (1.1.4)
46
+ rack
47
+ rake (0.9.2.2)
48
+ rdoc (3.11)
49
+ json (~> 1.4)
50
+ rspec (2.6.0)
51
+ rspec-core (~> 2.6.0)
52
+ rspec-expectations (~> 2.6.0)
53
+ rspec-mocks (~> 2.6.0)
54
+ rspec-core (2.6.4)
55
+ rspec-expectations (2.6.0)
56
+ diff-lcs (~> 1.1.2)
57
+ rspec-mocks (2.6.0)
58
+ sinatra (1.3.1)
59
+ rack (~> 1.3, >= 1.3.4)
60
+ rack-protection (~> 1.1, >= 1.1.2)
61
+ tilt (~> 1.3, >= 1.3.3)
62
+ tilt (1.3.3)
63
+
64
+ PLATFORMS
65
+ ruby
66
+
67
+ DEPENDENCIES
68
+ gibbon
69
+ omniauth-mailchimp!
70
+ rake
71
+ rspec (~> 2.6.0)
72
+ sinatra
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2011 Florian Mhun
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ 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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ #Mailchimp Strategie
2
+
3
+ MailChimp OAuth2 strategy for OmniAuth 1.0
4
+
5
+ #License
6
+
7
+ Copyright (c) 2011 Florian Mhun
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ 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/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,33 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'sinatra'
4
+ require 'omniauth'
5
+ require 'omniauth-mailchimp'
6
+
7
+ get '/' do
8
+ <<-HTML
9
+ <ul>
10
+ <li><a href='/auth/mailchimp'>Sign in with MailChimp</a></li>
11
+ </ul>
12
+ HTML
13
+ end
14
+
15
+ get '/auth/:provider/callback' do
16
+ content_type 'text/plain'
17
+ token = request.env['omniauth.auth']['credentials']['token']
18
+ dc = request.env['omniauth.auth']['extra']['user_hash']['dc']
19
+ "Standard API key is #{token}-#{dc}".inspect rescue "No data"
20
+ end
21
+
22
+ get '/auth/failure' do
23
+ content_type 'text/plain'
24
+ request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
25
+ end
26
+
27
+ use Rack::Session::Cookie, :secret => ENV['RACK_COOKIE_SECRET']
28
+
29
+ use OmniAuth::Builder do
30
+ provider :mailchimp, ENV["MC_KEY"], ENV["MC_SECRET"]
31
+ end
32
+
33
+ #run App.new
@@ -0,0 +1 @@
1
+ require "omniauth/mailchimp"
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/mailchimp'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Mailchimp
3
+ VERSION = "1.0"
4
+ end
5
+ end
@@ -0,0 +1,39 @@
1
+ require 'omniauth/strategies/oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Mailchimp < OmniAuth::Strategies::OAuth2
7
+
8
+ option :name, "mailchimp"
9
+
10
+ option :client_options, {
11
+ :site => "https://login.mailchimp.com",
12
+ :authorize_url => '/oauth2/authorize',
13
+ :token_url => '/oauth2/token'
14
+ }
15
+
16
+ def auth_hash
17
+ data = user_data
18
+ OmniAuth::Utils.deep_merge(
19
+ super, {
20
+ 'uid' => @access_token.client.id,
21
+ 'extra'=> {
22
+ 'user_hash' => data
23
+ }
24
+ }
25
+ )
26
+ end
27
+
28
+ def user_data
29
+ @data ||= MultiJson.decode(@access_token.get("https://login.mailchimp.com/oauth2/metadata").body)
30
+ rescue ::OAuth2::Error => e
31
+ if e.response.status == 302
32
+ @data ||= MultiJson.decode(@access_token.get(e.response.headers['location']))
33
+ else
34
+ raise e
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth/mailchimp/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+
7
+ gem.authors = ["Florian Mhun"]
8
+ gem.email = ["florian.mhun@gmail.com"]
9
+ gem.description = %q{MailChimp OAuth2 strategy for OmniAuth 1.0}
10
+ gem.summary = %q{MailChimp OAuth2 strategy for OmniAuth 1.0.}
11
+ gem.homepage = "http://floomoon.org/project/omniauth-mailchimp"
12
+
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ gem.name = "omniauth-mailchimp"
17
+ gem.require_paths = ["lib"]
18
+ gem.version = OmniAuth::Mailchimp::VERSION
19
+
20
+ gem.add_runtime_dependency 'omniauth-oauth2'
21
+
22
+ gem.add_development_dependency 'rspec', '~> 2.6.0'
23
+ gem.add_development_dependency 'rake'
24
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-mailchimp
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Florian Mhun
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-12-05 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70170874008840 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70170874008840
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70170874006400 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70170874006400
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70170874005820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.6.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70170874005820
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &70170874005280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70170874005280
58
+ description: MailChimp OAuth2 strategy for OmniAuth 1.0
59
+ email:
60
+ - florian.mhun@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - .gitignore
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - examples/config.ru
72
+ - lib/omniauth-mailchimp.rb
73
+ - lib/omniauth/mailchimp.rb
74
+ - lib/omniauth/mailchimp/version.rb
75
+ - lib/omniauth/strategies/mailchimp.rb
76
+ - omniauth-mailchimp.gemspec
77
+ homepage: http://floomoon.org/project/omniauth-mailchimp
78
+ licenses: []
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 1.8.10
98
+ signing_key:
99
+ specification_version: 3
100
+ summary: MailChimp OAuth2 strategy for OmniAuth 1.0.
101
+ test_files: []