omniauth-constantcontact 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/Gemfile +16 -0
- data/Guardfile +11 -0
- data/LICENSE.md +20 -0
- data/README.md +39 -0
- data/Rakefile +7 -0
- data/example/Gemfile +6 -0
- data/example/config.ru +30 -0
- data/lib/omniauth-constantcontact.rb +2 -0
- data/lib/omniauth-constantcontact/version.rb +5 -0
- data/lib/omniauth/strategies/constantcontact.rb +37 -0
- data/omniauth-constantcontact.gemspec +29 -0
- data/spec/omniauth/strategies/constantcontact_spec.rb +39 -0
- data/spec/spec_helper.rb +15 -0
- metadata +128 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem 'omniauth-oauth', :git => 'https://github.com/intridea/omniauth-oauth.git'
|
6
|
+
|
7
|
+
group :development, :test do
|
8
|
+
gem 'guard'
|
9
|
+
gem 'guard-rspec'
|
10
|
+
gem 'guard-bundler'
|
11
|
+
gem 'growl'
|
12
|
+
gem 'rb-fsevent'
|
13
|
+
gem 'multi_json'
|
14
|
+
gem 'nokogiri'
|
15
|
+
gem 'multi_xml'
|
16
|
+
end
|
data/Guardfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Caleb Clark
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# OmniAuth ConstantContact
|
2
|
+
|
3
|
+
This gem is an OmniAuth 1.0 Strategy for the [ConstantContact API](http://community.constantcontact.com/t5/Documentation/API-Documentation/ba-p/25125)
|
4
|
+
|
5
|
+
It supports the OmniAuth REST API which uses OAuth 1.0a.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add the strategy to your `Gemfile` alongside OmniAuth:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth'
|
13
|
+
gem 'omniauth-constantcontact'
|
14
|
+
```
|
15
|
+
|
16
|
+
Then integrate the strategy into your middleware:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
use OmniAuth::Builder do
|
20
|
+
provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
In Rails, you'll want to add to the middleware stack:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :constantcontact, ENV['CC_KEY'], ENV['CC_SECRET']
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
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
|
33
|
+
|
34
|
+
For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
|
35
|
+
|
36
|
+
|
37
|
+
## Copyright
|
38
|
+
|
39
|
+
Copyright (c) 2012 Caleb Clark. See [LICENSE](https://github.com/calebclark/omniauth-constantcontact/blob/master/LICENSE.md) for details.
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'sinatra'
|
5
|
+
#require 'sinatra/base'
|
6
|
+
require '../lib/omniauth-constantcontact'
|
7
|
+
|
8
|
+
#class App < Sinatra::Base
|
9
|
+
get '/' do
|
10
|
+
redirect '/auth/constantcontact'
|
11
|
+
end
|
12
|
+
|
13
|
+
get '/auth/:provider/callback' do
|
14
|
+
content_type 'application/json'
|
15
|
+
MultiJson.encode(request.env)
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/auth/failure' do
|
19
|
+
content_type 'application/json'
|
20
|
+
MultiJson.encode(request.env)
|
21
|
+
end
|
22
|
+
|
23
|
+
#end
|
24
|
+
|
25
|
+
use Rack::Session::Cookie
|
26
|
+
|
27
|
+
|
28
|
+
use OmniAuth::Builder do
|
29
|
+
provider :constantcontact, ENV['CC_API_KEY'], ENV['CC_CONSUMER_SECRET']
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'omniauth/strategies/oauth'
|
2
|
+
require 'multi_xml'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class ConstantContact < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, "constantcontact"
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:site => 'https://oauth.constantcontact.com',
|
11
|
+
:request_token_path => '/ws/oauth/request_token',
|
12
|
+
:access_token_path => '/ws/oauth/access_token',
|
13
|
+
:authorize_path => '/ws/oauth/confirm_access'
|
14
|
+
}
|
15
|
+
|
16
|
+
uid do
|
17
|
+
request.params['username']
|
18
|
+
end
|
19
|
+
|
20
|
+
info do
|
21
|
+
{
|
22
|
+
:email => raw_info['feed']['entry']['content']['Email']['EmailAddress']
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
extra do
|
27
|
+
{ 'raw_info' => raw_info }
|
28
|
+
end
|
29
|
+
|
30
|
+
def raw_info
|
31
|
+
@raw_info ||= MultiXml.parse(access_token.get("https://api.constantcontact.com/ws/customers/" + request.params['username'] + "/settings/emailaddresses").body)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
OmniAuth.config.add_camelization 'constantcontact', 'ConstantContact'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-constantcontact/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniauth-constantcontact"
|
7
|
+
s.version = OmniAuth::ConstantContact::VERSION
|
8
|
+
s.authors = ["Caleb Clark"]
|
9
|
+
s.email = ["cclark@mobilizationlabs.com"]
|
10
|
+
s.homepage = "http://github.com/calebclark/omniauth-constantcontact"
|
11
|
+
s.summary = %q{OmniAuth strategy for ConstantContact}
|
12
|
+
s.description = %q{OmniAuth strategy for ConstantContact}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniauth-constantcontact"
|
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-oauth', '~> 1.0'
|
22
|
+
s.add_runtime_dependency 'multi_xml'
|
23
|
+
|
24
|
+
s.add_development_dependency 'rspec', '~> 2.7.0'
|
25
|
+
s.add_development_dependency 'rake'
|
26
|
+
s.add_development_dependency 'webmock'
|
27
|
+
s.add_development_dependency 'rack-test'
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "OmniAuth::Strategies::ConstantContact" do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::ConstantContact.new(nil, @options || {})
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should add a camelization for itself' do
|
9
|
+
OmniAuth::Utils.camelize('constantcontact').should == 'ConstantContact'
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'client options' do
|
13
|
+
it 'has correct ConstantContact site' do
|
14
|
+
subject.options.client_options.site.should eq('https://oauth.constantcontact.com')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has correct request token path' do
|
18
|
+
subject.options.client_options.request_token_path.should eq('/ws/oauth/request_token')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has correct access token path' do
|
22
|
+
subject.options.client_options.access_token_path.should eq('/ws/oauth/access_token')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has correct authorize url' do
|
26
|
+
subject.options.client_options.authorize_path.should eq('/ws/oauth/confirm_access')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context '#uid' do
|
31
|
+
before :each do
|
32
|
+
subject.stub(:raw_info) { { 'id' => '123' } }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns the id from raw_info' do
|
36
|
+
subject.uid.should eq('123')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-constantcontact'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include WebMock::API
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
15
|
+
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-constantcontact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Caleb Clark
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-07 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-oauth
|
16
|
+
requirement: &70103291628980 !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: *70103291628980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_xml
|
27
|
+
requirement: &70103291628440 !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: *70103291628440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70103291627740 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.7.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70103291627740
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: &70103291627240 !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: *70103291627240
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: webmock
|
60
|
+
requirement: &70103291626720 !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: *70103291626720
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: &70103291626160 !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: *70103291626160
|
80
|
+
description: OmniAuth strategy for ConstantContact
|
81
|
+
email:
|
82
|
+
- cclark@mobilizationlabs.com
|
83
|
+
executables: []
|
84
|
+
extensions: []
|
85
|
+
extra_rdoc_files: []
|
86
|
+
files:
|
87
|
+
- .gitignore
|
88
|
+
- .rspec
|
89
|
+
- Gemfile
|
90
|
+
- Guardfile
|
91
|
+
- LICENSE.md
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- example/Gemfile
|
95
|
+
- example/config.ru
|
96
|
+
- lib/omniauth-constantcontact.rb
|
97
|
+
- lib/omniauth-constantcontact/version.rb
|
98
|
+
- lib/omniauth/strategies/constantcontact.rb
|
99
|
+
- omniauth-constantcontact.gemspec
|
100
|
+
- spec/omniauth/strategies/constantcontact_spec.rb
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
homepage: http://github.com/calebclark/omniauth-constantcontact
|
103
|
+
licenses: []
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project: omniauth-constantcontact
|
122
|
+
rubygems_version: 1.8.15
|
123
|
+
signing_key:
|
124
|
+
specification_version: 3
|
125
|
+
summary: OmniAuth strategy for ConstantContact
|
126
|
+
test_files:
|
127
|
+
- spec/omniauth/strategies/constantcontact_spec.rb
|
128
|
+
- spec/spec_helper.rb
|