omniauth-ctct 1.0.5

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4dda9cab5db953fbe56331cdea4935e690c12e8c
4
+ data.tar.gz: afdb13e5fce7ca7b8ae95c4ec5294f6018f3b593
5
+ SHA512:
6
+ metadata.gz: 65795d64f851ff3ed2d34150ad6f727ef33ffabdef5193da3e15528fea5d8a25e4b9ee75f435cff88e13e57f2b7d387bd15cebc14a466cb99fb706eb92bd142b
7
+ data.tar.gz: be1dae250dcea434f179b7c8dd079dec572de8c8abf99de59163b0cd6e3494228d88ab02aa885ce960b108b9910ed02aea4fb93964676f1841e78728a6e6ddd6
data/.gitignore ADDED
@@ -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/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
data/Guardfile ADDED
@@ -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.
data/README.md ADDED
@@ -0,0 +1,64 @@
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
+ Many thanks to [Caleb Clark](https://github.com/calebclark/omniauth-constantcontact) for writing the original OmniAuth strategy. This builds on his work.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'omniauth-constantcontact2'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install omniauth-constantcontact2
22
+
23
+ ## Usage
24
+
25
+ Then integrate the strategy into your middleware:
26
+
27
+ ```ruby
28
+ use OmniAuth::Builder do
29
+ provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
30
+ end
31
+ ```
32
+
33
+ In Rails, you'll want to add to the middleware stack:
34
+
35
+ ```ruby
36
+ Rails.application.config.middleware.use OmniAuth::Builder do
37
+ provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
38
+ end
39
+ ```
40
+
41
+ ** Ensure that you have provided the correct Redirect URI in Constant Contact when you generated the Key.
42
+ You are likely to see an error stating "invalid redirect" if the Request URI does not match the one from your environment.
43
+
44
+ In development for example the Redirect URI is
45
+
46
+ http://localhost:3000/auth/constantcontact/callback
47
+
48
+
49
+ 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
50
+
51
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
52
+
53
+
54
+ ## Contributing
55
+
56
+ 1. Fork it
57
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
58
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
59
+ 4. Push to the branch (`git push origin my-new-feature`)
60
+ 5. Create new Pull Request
61
+
62
+ ## Copyright
63
+
64
+ Copyright (c) 2012 Aditya Sanghi. See [LICENSE](https://github.com/asanghi/omniauth-constantcontact2/blob/master/LICENSE.md) for details.
data/Rakefile ADDED
@@ -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,61 @@
1
+ require 'omniauth-oauth2'
2
+ require 'multi_json'
3
+ require 'multi_xml'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class Ctct < OmniAuth::Strategies::OAuth2
8
+
9
+ DEFAULT_RESPONSE_TYPE = 'code'
10
+ DEFAULT_GRANT = 'authorization_code'
11
+ API_PATH = 'https://api.constantcontact.com/v2'
12
+
13
+ option :name, "constantcontact"
14
+
15
+ option :client_options, {
16
+ :site => 'https://oauth2.constantcontact.com',
17
+ :authorize_url => '/oauth2/oauth/siteowner/authorize',
18
+ :token_url => '/oauth2/oauth/token'
19
+ }
20
+
21
+ def authorize_params
22
+ super.tap do |params|
23
+ params[:response_type] ||= DEFAULT_RESPONSE_TYPE
24
+ params[:client_id] = client.id
25
+ end
26
+ end
27
+
28
+ def token_params
29
+ super.tap do |params|
30
+ params[:grant_type] ||= DEFAULT_GRANT
31
+ params[:client_id] = client.id
32
+ params[:client_secret] = client.secret
33
+ end
34
+ end
35
+
36
+ uid do
37
+ request.params['username']
38
+ end
39
+
40
+ info do
41
+ {
42
+ email: raw_info['email']
43
+ }
44
+ end
45
+
46
+ extra do
47
+ { 'raw_info' => raw_info }
48
+ end
49
+
50
+ def raw_info
51
+ options = {
52
+ params: {api_key: client.id},
53
+ headers: {'Authorization' => "Bearer #{access_token.token}"}
54
+ }
55
+ @raw_info ||= JSON.parse(access_token.get("#{API_PATH}/account/info", options).body)
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ OmniAuth.config.add_camelization 'constantcontact', 'ConstantContact2'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Ctct
3
+ VERSION = "1.0.5"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-ctct/version"
2
+ require 'omniauth/strategies/ctct'
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-ctct/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = "omniauth-ctct"
6
+ gem.version = Omniauth::Ctct::VERSION
7
+ gem.authors = ["Aditya Sanghi", "David Jellesma"]
8
+ gem.email = ["asanghi@me.com", "djellesma@constantcontact.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/dsjellz/omniauth-ctct"
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'
21
+ gem.add_dependency 'multi_xml'
22
+
23
+ gem.add_development_dependency 'rake'
24
+ gem.add_development_dependency 'rspec', '~> 2.8'
25
+ gem.add_development_dependency 'rack-test'
26
+ gem.add_development_dependency 'simplecov'
27
+ end
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'omniauth-ctct'
3
+
4
+ describe OmniAuth::Strategies::Ctct do
5
+ subject do
6
+ OmniAuth::Strategies::Ctct.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")
14
+ end
15
+
16
+ it 'should have the correct authorization url' do
17
+ subject.client.options[:authorize_url].should eq("/oauth2/oauth/siteowner/authorize")
18
+ end
19
+
20
+ it 'should have the correct token url' do
21
+ subject.client.options[:token_url].should eq('/oauth2/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/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-ctct'
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,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-ctct
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Aditya Sanghi
8
+ - David Jellesma
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-10-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: omniauth-oauth2
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: '1.0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: '1.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: multi_json
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: multi_xml
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '2.8'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ~>
96
+ - !ruby/object:Gem::Version
97
+ version: '2.8'
98
+ - !ruby/object:Gem::Dependency
99
+ name: rack-test
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: simplecov
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: OmniAuth Strategy for Constant Contact using OAuth2
127
+ email:
128
+ - asanghi@me.com
129
+ - djellesma@constantcontact.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - .travis.yml
136
+ - Gemfile
137
+ - Guardfile
138
+ - LICENSE
139
+ - README.md
140
+ - Rakefile
141
+ - lib/omniauth-ctct.rb
142
+ - lib/omniauth-ctct/version.rb
143
+ - lib/omniauth/strategies/ctct.rb
144
+ - omniauth-ctct.gemspec
145
+ - spec/omniauth/strategies/ctct_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/shared_examples.rb
148
+ homepage: https://github.com/dsjellz/omniauth-ctct
149
+ licenses: []
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '>='
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.0.14
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: OmniAuth Strategy for Constant Contact using OAuth2
171
+ test_files:
172
+ - spec/omniauth/strategies/ctct_spec.rb
173
+ - spec/spec_helper.rb
174
+ - spec/support/shared_examples.rb