Skip to content

Commit 67dcd9c

Browse files
committed
init
0 parents  commit 67dcd9c

File tree

14 files changed

+251
-0
lines changed

14 files changed

+251
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.gem
2+
.bundle
3+
Gemfile.lock
4+
pkg/*
5+
*.swp

.rvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rvm 1.9.2@omniauth-intuit

Gemfile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
source "http://rubygems.org"
2+
3+
# Specify your gem's dependencies in omniauth-intuit.gemspec
4+
gemspec
5+
6+
gem 'omniauth-intuit', :git => 'https://github.com/jaigouk/omniauth-intuit.git'
7+
8+
group :development, :test do
9+
gem 'guard'
10+
gem 'guard-rspec'
11+
gem 'guard-bundler'
12+
gem 'growl'
13+
gem 'rb-fsevent'
14+
gem 'multi_json'
15+
end

Guardfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
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+
8+
guard 'bundler' do
9+
watch('Gemfile')
10+
watch(/^.+\.gemspec/)
11+
end

README.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# OmniAuth Intuit
2+
3+
**Note:** This gem is designed to work with the unreleased OmniAuth 1.0 library. It will not be officially released on RubyGems.org until OmniAuth 1.0 is released.
4+
5+
This gem contains the LinkedIn strategy for OmniAuth.
6+
7+
Intuit uses the OAuth 1.0a flow, you can read about it here: https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0030_Intuit_Anywhere/0036_Coding_Your_App/0050_OAuth_for_Intuit_Anywhere
8+
9+
## How To Use It
10+
11+
Usage is as per any other OmniAuth 1.0 strategy. So let's say you're using Rails, you need to add the strategy to your `Gemfile` along side omniauth:
12+
13+
gem 'omniauth'
14+
gem 'omniauth-intuit'
15+
16+
Of course if one or both of these are unreleased, you may have to pull them in directly from github e.g.:
17+
18+
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git'
19+
gem 'omniauth-intuit', :git => 'https://github.com/jaigouk/omniauth-intuit.git'
20+
21+
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`:
22+
23+
Rails.application.config.middleware.use OmniAuth::Builder do
24+
provider :intuit, "consumer_key", "consumer_secret"
25+
end
26+
27+
You will obviously have to put in your key and secret, which you get when you register your app with LinkedIn (they call them API Key and Secret Key).
28+
29+
Now just follow the README at: https://github.com/intridea/omniauth
30+
31+
32+
## Note on Patches/Pull Requests
33+
34+
- Fork the project.
35+
- Make your feature addition or bug fix.
36+
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
37+
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
38+
- Send me a pull request. Bonus points for topic branches.
39+
40+
## License
41+
42+
Copyright (c) 2011 by Jaigouk Kim
43+
44+
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:
45+
46+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47+
48+
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.

Rakefile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require 'bundler/gem_tasks'
2+
require 'rspec/core/rake_task'
3+
4+
RSpec::Core::RakeTask.new(:spec)
5+
6+
task :default => :spec

example/Gemfile

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
source :rubygems
2+
3+
gem 'sinatra'
4+
gem 'multi_json'
5+
gem 'omniauth-intuit', :path => '../'
6+
#gem 'omniauth-intuit'

example/config.ru

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
require 'bundler/setup'
2+
require 'sinatra/base'
3+
require 'omniauth-intuit'
4+
5+
class App < Sinatra::Base
6+
get '/' do
7+
redirect '/auth/intuit'
8+
end
9+
10+
get '/auth/:provider/callback' do
11+
content_type 'application/json'
12+
MultiJson.encode(request.env)
13+
end
14+
15+
get '/auth/failure' do
16+
content_type 'application/json'
17+
MultiJson.encode(request.env)
18+
end
19+
end
20+
21+
use Rack::Session::Cookie
22+
23+
use OmniAuth::Builder do
24+
provider :intuit, ENV['INTUIT_CONSUMER_KEY'], ENV['INTUIT_CONSUMER_SECRET']
25+
end
26+
27+
run App.new

lib/omniauth-intuit.rb

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require "omniauth-intuit/version"
2+
require 'omniauth/strategies/intuit'
3+
4+
5+
module Omniauth
6+
module Intuit
7+
# Your code goes here...
8+
end
9+
end

lib/omniauth-intuit/version.rb

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Omniauth
2+
module Intuit
3+
VERSION = "0.0.1"
4+
end
5+
end

lib/omniauth/strategies/intuit.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
require 'omniauth/strategies/oauth'
2+
3+
module OmniAuth
4+
module Strategies
5+
class Intuit < OmniAuth::Strategies::OAuth
6+
option :name, "intuit"
7+
8+
option :client_options, {
9+
:site => 'https://oauth.intuit.com',
10+
:request_token_path => '/oauth/v1/get_request_token',
11+
:access_token_path => '/oauth/v1/get_access_token',
12+
:authorize_url => "https://appcenter.intuit.com/Connect/Begin"
13+
}
14+
15+
uid{ raw_info['id'] }
16+
17+
info do
18+
{
19+
:first_name => raw_info['firstName'],
20+
:last_name => raw_info['lastName'],
21+
:name => "#{raw_info['firstName']} #{raw_info['lastName']}",
22+
:urls => {
23+
'public_profile' => raw_info['publicProfileUrl']
24+
}
25+
}
26+
end
27+
28+
extra do
29+
{ 'raw_info' => raw_info }
30+
end
31+
32+
def raw_info
33+
@raw_info ||= MultiJson.decode(access_token.get("https://appcenter.intuit.com/Connect").body)
34+
end
35+
end
36+
end
37+
end
38+
39+
OmniAuth.config.add_camelization 'intuit', 'Intuit'
40+

omniauth-intuit.gemspec

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- encoding: utf-8 -*-
2+
$:.push File.expand_path("../lib", __FILE__)
3+
require "omniauth-intuit/version"
4+
5+
Gem::Specification.new do |s|
6+
s.name = "omniauth-intuit"
7+
s.version = Omniauth::Linkedin::VERSION
8+
s.authors = ["Jaigouk Kim"]
9+
s.email = ["[email protected]"]
10+
s.homepage = "https://github.com/jaigouk/omniauth-intuit"
11+
s.summary = %q{Intuit strategy for OmniAuth.}
12+
s.description = %q{Intuit strategy for OmniAuth.}
13+
14+
s.files = `git ls-files`.split("\n")
15+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17+
s.require_paths = ["lib"]
18+
19+
s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0'
20+
21+
s.add_development_dependency 'rspec', '~> 2.7.0'
22+
s.add_development_dependency 'rake'
23+
s.add_development_dependency 'webmock'
24+
s.add_development_dependency 'rack-test'
25+
end
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper'
2+
3+
describe "OmniAuth::Strategies::Intuit" do
4+
subject do
5+
OmniAuth::Strategies::LinkedIn.new(nil, @options || {})
6+
end
7+
8+
it 'should add a camelization for itself' do
9+
OmniAuth::Utils.camelize('intuit').should == 'Intuit'
10+
end
11+
12+
context 'client options' do
13+
it 'has correct Intuit site' do
14+
subject.options.client_options.site.should eq('https://oauth.intuit.com')
15+
end
16+
17+
it 'has correct request token path' do
18+
subject.options.client_options.request_token_path.should eq('/oauth/v1/get_request_token')
19+
end
20+
21+
it 'has correct access token path' do
22+
subject.options.client_options.access_token_path.should eq('/oauth/v1/get_access_token')
23+
end
24+
25+
it 'has correct authorize url' do
26+
subject.options.client_options.authorize_url.should eq('https://appcenter.intuit.com/Connect/Begin')
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

spec/spec_helper.rb

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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-intuit'
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

0 commit comments

Comments
 (0)