forked from activecell/omniauth-intuit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 67dcd9c
Showing
14 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.gem | ||
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
*.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rvm 1.9.2@omniauth-intuit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
source "http://rubygems.org" | ||
|
||
# Specify your gem's dependencies in omniauth-intuit.gemspec | ||
gemspec | ||
|
||
gem 'omniauth-intuit', :git => 'https://github.com/jaigouk/omniauth-intuit.git' | ||
|
||
group :development, :test do | ||
gem 'guard' | ||
gem 'guard-rspec' | ||
gem 'guard-bundler' | ||
gem 'growl' | ||
gem 'rb-fsevent' | ||
gem 'multi_json' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
guard 'rspec', :version => 2 do | ||
watch(%r{^spec/.+_spec\.rb$}) | ||
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } | ||
watch('spec/spec_helper.rb') { "spec" } | ||
end | ||
|
||
|
||
guard 'bundler' do | ||
watch('Gemfile') | ||
watch(/^.+\.gemspec/) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# OmniAuth Intuit | ||
|
||
**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. | ||
|
||
This gem contains the LinkedIn strategy for OmniAuth. | ||
|
||
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 | ||
|
||
## How To Use It | ||
|
||
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: | ||
|
||
gem 'omniauth' | ||
gem 'omniauth-intuit' | ||
|
||
Of course if one or both of these are unreleased, you may have to pull them in directly from github e.g.: | ||
|
||
gem 'omniauth', :git => 'https://github.com/intridea/omniauth.git' | ||
gem 'omniauth-intuit', :git => 'https://github.com/jaigouk/omniauth-intuit.git' | ||
|
||
Once these are in, you need to add the following to your `config/initializers/omniauth.rb`: | ||
|
||
Rails.application.config.middleware.use OmniAuth::Builder do | ||
provider :intuit, "consumer_key", "consumer_secret" | ||
end | ||
|
||
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). | ||
|
||
Now just follow the README at: https://github.com/intridea/omniauth | ||
|
||
|
||
## Note on Patches/Pull Requests | ||
|
||
- Fork the project. | ||
- Make your feature addition or bug fix. | ||
- Add tests for it. This is important so I don’t break it in a future version unintentionally. | ||
- 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) | ||
- Send me a pull request. Bonus points for topic branches. | ||
|
||
## License | ||
|
||
Copyright (c) 2011 by Jaigouk Kim | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
task :default => :spec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source :rubygems | ||
|
||
gem 'sinatra' | ||
gem 'multi_json' | ||
gem 'omniauth-intuit', :path => '../' | ||
#gem 'omniauth-intuit' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require 'bundler/setup' | ||
require 'sinatra/base' | ||
require 'omniauth-intuit' | ||
|
||
class App < Sinatra::Base | ||
get '/' do | ||
redirect '/auth/intuit' | ||
end | ||
|
||
get '/auth/:provider/callback' do | ||
content_type 'application/json' | ||
MultiJson.encode(request.env) | ||
end | ||
|
||
get '/auth/failure' do | ||
content_type 'application/json' | ||
MultiJson.encode(request.env) | ||
end | ||
end | ||
|
||
use Rack::Session::Cookie | ||
|
||
use OmniAuth::Builder do | ||
provider :intuit, ENV['INTUIT_CONSUMER_KEY'], ENV['INTUIT_CONSUMER_SECRET'] | ||
end | ||
|
||
run App.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
require "omniauth-intuit/version" | ||
require 'omniauth/strategies/intuit' | ||
|
||
|
||
module Omniauth | ||
module Intuit | ||
# Your code goes here... | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Omniauth | ||
module Intuit | ||
VERSION = "0.0.1" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
require 'omniauth/strategies/oauth' | ||
|
||
module OmniAuth | ||
module Strategies | ||
class Intuit < OmniAuth::Strategies::OAuth | ||
option :name, "intuit" | ||
|
||
option :client_options, { | ||
:site => 'https://oauth.intuit.com', | ||
:request_token_path => '/oauth/v1/get_request_token', | ||
:access_token_path => '/oauth/v1/get_access_token', | ||
:authorize_url => "https://appcenter.intuit.com/Connect/Begin" | ||
} | ||
|
||
uid{ raw_info['id'] } | ||
|
||
info do | ||
{ | ||
:first_name => raw_info['firstName'], | ||
:last_name => raw_info['lastName'], | ||
:name => "#{raw_info['firstName']} #{raw_info['lastName']}", | ||
:urls => { | ||
'public_profile' => raw_info['publicProfileUrl'] | ||
} | ||
} | ||
end | ||
|
||
extra do | ||
{ 'raw_info' => raw_info } | ||
end | ||
|
||
def raw_info | ||
@raw_info ||= MultiJson.decode(access_token.get("https://appcenter.intuit.com/Connect").body) | ||
end | ||
end | ||
end | ||
end | ||
|
||
OmniAuth.config.add_camelization 'intuit', 'Intuit' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# -*- encoding: utf-8 -*- | ||
$:.push File.expand_path("../lib", __FILE__) | ||
require "omniauth-intuit/version" | ||
|
||
Gem::Specification.new do |s| | ||
s.name = "omniauth-intuit" | ||
s.version = Omniauth::Linkedin::VERSION | ||
s.authors = ["Jaigouk Kim"] | ||
s.email = ["jaigouk@gmail.com"] | ||
s.homepage = "https://github.com/jaigouk/omniauth-intuit" | ||
s.summary = %q{Intuit strategy for OmniAuth.} | ||
s.description = %q{Intuit strategy for OmniAuth.} | ||
|
||
s.files = `git ls-files`.split("\n") | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
s.require_paths = ["lib"] | ||
|
||
s.add_runtime_dependency 'omniauth-oauth', '~> 1.0.0' | ||
|
||
s.add_development_dependency 'rspec', '~> 2.7.0' | ||
s.add_development_dependency 'rake' | ||
s.add_development_dependency 'webmock' | ||
s.add_development_dependency 'rack-test' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe "OmniAuth::Strategies::Intuit" do | ||
subject do | ||
OmniAuth::Strategies::LinkedIn.new(nil, @options || {}) | ||
end | ||
|
||
it 'should add a camelization for itself' do | ||
OmniAuth::Utils.camelize('intuit').should == 'Intuit' | ||
end | ||
|
||
context 'client options' do | ||
it 'has correct Intuit site' do | ||
subject.options.client_options.site.should eq('https://oauth.intuit.com') | ||
end | ||
|
||
it 'has correct request token path' do | ||
subject.options.client_options.request_token_path.should eq('/oauth/v1/get_request_token') | ||
end | ||
|
||
it 'has correct access token path' do | ||
subject.options.client_options.access_token_path.should eq('/oauth/v1/get_access_token') | ||
end | ||
|
||
it 'has correct authorize url' do | ||
subject.options.client_options.authorize_url.should eq('https://appcenter.intuit.com/Connect/Begin') | ||
end | ||
end | ||
|
||
context '#uid' do | ||
before :each do | ||
subject.stub(:raw_info) { { 'id' => '123' } } | ||
end | ||
|
||
it 'returns the id from raw_info' do | ||
subject.uid.should eq('123') | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
$:.unshift File.expand_path('..', __FILE__) | ||
$:.unshift File.expand_path('../../lib', __FILE__) | ||
|
||
require 'rspec' | ||
require 'rack/test' | ||
require 'webmock/rspec' | ||
require 'omniauth' | ||
require 'omniauth-intuit' | ||
|
||
RSpec.configure do |config| | ||
config.include WebMock::API | ||
config.include Rack::Test::Methods | ||
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy | ||
end |