omniauth-constantcontact2 1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'guard'
7
+ gem 'guard-rspec'
8
+ gem 'guard-bundler'
9
+ gem 'rb-fsevent'
10
+ gem 'growl'
11
+ gem 'multi_json'
12
+ end
@@ -0,0 +1,10 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-constantcontact2.gemspec')
10
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Aditya Sanghi
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,54 @@
1
+ # Omniauth::ConstantContact2
2
+
3
+ This gem is an OmniAuth 2.0 Strategy for the [ConstantContact API](http://http://community.constantcontact.com/t5/Documentation/Authentication-using-OAuth-2-0-new-October-2011/ba-p/38313)
4
+
5
+ It supports the OmniAuth REST API which uses OAuth 2.0
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'omniauth-constantcontact2'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install omniauth-constantcontact2
20
+
21
+ ## Usage
22
+
23
+ Then integrate the strategy into your middleware:
24
+
25
+ ```ruby
26
+ use OmniAuth::Builder do
27
+ provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
28
+ end
29
+ ```
30
+
31
+ In Rails, you'll want to add to the middleware stack:
32
+
33
+ ```ruby
34
+ Rails.application.config.middleware.use OmniAuth::Builder do
35
+ provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
36
+ end
37
+ ```
38
+
39
+ You will have to put in your consumer key and secret, which you can find at http://community.constantcontact.com/t5/Documentation/API-Keys/ba-p/25015
40
+
41
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
42
+
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
51
+
52
+ ## Copyright
53
+
54
+ Copyright (c) 2012 Aditya Sanghi. See [LICENSE](https://github.com/asanghi/omniauth-constantcontact2/blob/master/LICENSE.md) for details.
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-constantcontact2/version"
2
+ require 'omniauth/strategies/constantcontact2'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module ConstantContact2
3
+ VERSION = "1.0"
4
+ end
5
+ end
@@ -0,0 +1,55 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class ConstantContact2 < OmniAuth::Strategies::OAuth2
7
+
8
+ DEFAULT_RESPONSE_TYPE = 'code'
9
+ DEFAULT_GRANT = 'authorization_code'
10
+
11
+ option :name, "constantcontact"
12
+
13
+ option :client_options, {
14
+ :site => 'https://oauth2.constantcontact.com/oauth2/oauth',
15
+ :authorize_url => '/siteowner/authorize',
16
+ :token_url => '/token'
17
+ }
18
+
19
+ def authorize_params
20
+ super.tap do |params|
21
+ params[:response_type] ||= DEFAULT_RESPONSE_TYPE
22
+ params[:client_id] = client.id
23
+ end
24
+ end
25
+
26
+ def token_params
27
+ super.tap do |params|
28
+ params[:grant_type] ||= DEFAULT_GRANT
29
+ params[:client_id] = client.id
30
+ params[:client_secret] = client.secret
31
+ end
32
+ end
33
+
34
+ uid do
35
+ request.params['username']
36
+ end
37
+
38
+ info do
39
+ {
40
+ :email => raw_info['feed']['entry']['content']['Email']['EmailAddress']
41
+ }
42
+ end
43
+
44
+ extra do
45
+ { 'raw_info' => raw_info }
46
+ end
47
+
48
+ def raw_info
49
+ @raw_info ||= access_token.get("https://api.constantcontact.com/ws/customers/" + request.params['username'] + "/settings/emailaddresses").parsed
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ OmniAuth.config.add_camelization 'constantcontact', 'ConstantContact2'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-constantcontact2/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "omniauth-constantcontact2"
6
+ gem.version = Omniauth::ConstantContact2::VERSION
7
+ gem.authors = ["Aditya Sanghi"]
8
+ gem.email = ["asanghi@me.com"]
9
+ gem.description = %q{OmniAuth Strategy for Constant Contact using OAuth2}
10
+ gem.summary = %q{OmniAuth Strategy for Constant Contact using OAuth2}
11
+ gem.homepage = "https://github.com/asanghi/omniauth-constantcontact2"
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.require_paths = ["lib"]
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
20
+ gem.add_dependency 'multi_json', '~> 1.0.3'
21
+ gem.add_development_dependency 'rspec', '~> 2.8'
22
+ gem.add_development_dependency 'rack-test'
23
+ gem.add_development_dependency 'simplecov'
24
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-constantcontact2'
3
+
4
+ describe OmniAuth::Strategies::ConstantContact2 do
5
+ subject do
6
+ OmniAuth::Strategies::ConstantContact2.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 Constant Contact site' do
13
+ subject.client.site.should eq("https://oauth2.constantcontact.com/oauth2/oauth")
14
+ end
15
+
16
+ it 'should have the correct authorization url' do
17
+ subject.client.options[:authorize_url].should eq("/siteowner/authorize")
18
+ end
19
+
20
+ it 'should have the correct token url' do
21
+ subject.client.options[:token_url].should eq('/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/constantcontact/callback')
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,16 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'omniauth'
8
+ require 'omniauth-constantcontact2'
9
+
10
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
16
+
@@ -0,0 +1,40 @@
1
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
2
+ # Thanks to Josh Ellithorpe for this file -Will
3
+
4
+ shared_examples 'an oauth2 strategy' do
5
+ describe '#client' do
6
+ it 'should be initialized with symbolized client_options' do
7
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
8
+ subject.client.options[:authorize_url].should == 'https://example.com'
9
+ end
10
+ end
11
+
12
+ describe '#authorize_params' do
13
+ it 'should include any authorize params passed in the :authorize_params option' do
14
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
15
+ subject.authorize_params['foo'].should eq('bar')
16
+ subject.authorize_params['baz'].should eq('zip')
17
+ end
18
+
19
+ it 'should include top-level options that are marked as :authorize_options' do
20
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
21
+ subject.authorize_params['scope'].should eq('bar')
22
+ subject.authorize_params['foo'].should eq('baz')
23
+ end
24
+ end
25
+
26
+ describe '#token_params' do
27
+ it 'should include any token params passed in the :token_params option' do
28
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
29
+ subject.token_params['foo'].should eq('bar')
30
+ subject.token_params['baz'].should eq('zip')
31
+ end
32
+
33
+ it 'should include top-level options that are marked as :token_options' do
34
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
35
+ subject.token_params['scope'].should eq('bar')
36
+ subject.token_params['foo'].should eq('baz')
37
+ end
38
+ end
39
+ end
40
+
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-constantcontact2
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Aditya Sanghi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &70260254666760 !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: *70260254666760
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &70260254666200 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70260254666200
36
+ - !ruby/object:Gem::Dependency
37
+ name: multi_json
38
+ requirement: &70260254665620 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 1.0.3
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70260254665620
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec
49
+ requirement: &70260254665020 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2.8'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70260254665020
58
+ - !ruby/object:Gem::Dependency
59
+ name: rack-test
60
+ requirement: &70260254664520 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70260254664520
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70260254663940 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70260254663940
80
+ description: OmniAuth Strategy for Constant Contact using OAuth2
81
+ email:
82
+ - asanghi@me.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - .gitignore
88
+ - Gemfile
89
+ - Guardfile
90
+ - LICENSE
91
+ - README.md
92
+ - Rakefile
93
+ - lib/omniauth-constantcontact2.rb
94
+ - lib/omniauth-constantcontact2/version.rb
95
+ - lib/omniauth/strategies/constantcontact2.rb
96
+ - omniauth-constantcontact2.gemspec
97
+ - spec/omniauth/strategies/constantcontact2_spec.rb
98
+ - spec/spec_helper.rb
99
+ - spec/support/shared_examples.rb
100
+ homepage: https://github.com/asanghi/omniauth-constantcontact2
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.8.13
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: OmniAuth Strategy for Constant Contact using OAuth2
124
+ test_files:
125
+ - spec/omniauth/strategies/constantcontact2_spec.rb
126
+ - spec/spec_helper.rb
127
+ - spec/support/shared_examples.rb