omniauth-xero 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-xero.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kale Worsley
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,66 @@
1
+ # Omniauth Xero
2
+
3
+ [Omniauth Xero](https://github.com/kaleworsley/omniauth-xero) is an [OmniAuth](https://github.com/intridea/omniauth) authentication strategy for [Xero](http://www.xero.com).
4
+
5
+ ## Installation
6
+
7
+ Add this to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'omniauth', '~> 1.0.0'
11
+ gem 'omniauth-xero'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```bash
17
+ bundle
18
+ ```
19
+
20
+ Or install it yourself as:
21
+
22
+ ```bash
23
+ gem install omniauth-xero
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ Register your public application on the [Xero API site](https://api.xero.com/Application/Add).
29
+
30
+ For a Rack application:
31
+
32
+ ```ruby
33
+ use OmniAuth::Builder do
34
+ provider :xero, CONSUMER_KEY, CONSUMER_SECRET
35
+ end
36
+ ```
37
+
38
+ For a Rails application:
39
+
40
+ ```ruby
41
+ # config/intializers/omniauth.rb
42
+ Rails.application.config.middleware.use OmniAuth::Builder do
43
+ provider :xero, CONSUMER_KEY, CONSUMER_SECRET
44
+ end
45
+ ```
46
+
47
+ Or, if you use [devise](https://github.com/plataformatec/devise) for authentication:
48
+
49
+ ```ruby
50
+ # config/initializers/devise.rb
51
+ Devise.setup do |config|
52
+ config.omniauth :xero, CONSUMER_KEY, CONSUMER_SECRET
53
+ end
54
+ ```
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
63
+
64
+ ## Copyright
65
+
66
+ Copyright (c) 2013 Kale Worsley. See [LICENSE.txt](LICENSE.txt) for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,35 @@
1
+ require "omniauth/strategies/oauth"
2
+ require "multi_xml"
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Xero < OmniAuth::Strategies::OAuth
7
+
8
+ args [:consumer_key, :consumer_secret]
9
+
10
+ option :client_options, {
11
+ :access_token_path => "/oauth/AccessToken",
12
+ :authorize_path => "/oauth/Authorize",
13
+ :request_token_path => "/oauth/RequestToken",
14
+ :site => "https://api.xero.com",
15
+ }
16
+
17
+ info do
18
+ {
19
+ :first_name => raw_info["FirstName"],
20
+ :last_name => raw_info["LastName"],
21
+ }
22
+ end
23
+
24
+ uid { raw_info["UserID"] }
25
+
26
+ extra do
27
+ { "raw_info" => raw_info }
28
+ end
29
+
30
+ def raw_info
31
+ @raw_info ||= MultiXml.parse(access_token.get("/api.xro/2.0/Users").body)["Response"]["Users"]["User"]
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth/xero/version"
2
+ require "omniauth/strategies/xero"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Xero
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "omniauth/xero/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "omniauth-xero"
8
+ spec.version = Omniauth::Xero::VERSION
9
+ spec.authors = ["Kale Worsley"]
10
+ spec.email = ["kale@worsley.co.nz"]
11
+ spec.description = "Xero authentication strategy for OmniAuth."
12
+ spec.summary = "Xero authentication strategy for OmniAuth."
13
+ spec.homepage = "http://github.com/kaleworsley/omniauth-xero"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency "omniauth-oauth", "~> 1.0"
22
+ spec.add_runtime_dependency "multi_xml", "~> 0.5"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec", "~> 2.0"
27
+
28
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::Xero" do
4
+ subject do
5
+ OmniAuth::Strategies::Xero.new(nil, {})
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'has correct site' do
10
+ subject.options.client_options.site.should eq('https://api.xero.com')
11
+ end
12
+
13
+ it 'has correct request token path' do
14
+ subject.options.client_options.request_token_path.should eq('/oauth/RequestToken')
15
+ end
16
+
17
+ it 'has correct access token path' do
18
+ subject.options.client_options.access_token_path.should eq('/oauth/AccessToken')
19
+ end
20
+
21
+ it 'has correct authorize path' do
22
+ subject.options.client_options.authorize_path.should eq('/oauth/Authorize')
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,10 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'omniauth'
6
+ require 'omniauth/xero'
7
+
8
+ RSpec.configure do |config|
9
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
10
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-xero
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kale Worsley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_xml
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '0.5'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.5'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rspec
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: '2.0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.0'
94
+ description: Xero authentication strategy for OmniAuth.
95
+ email:
96
+ - kale@worsley.co.nz
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - LICENSE.txt
104
+ - README.md
105
+ - Rakefile
106
+ - lib/omniauth/strategies/xero.rb
107
+ - lib/omniauth/xero.rb
108
+ - lib/omniauth/xero/version.rb
109
+ - omniauth-xero.gemspec
110
+ - spec/omniauth/strategies/xero_spec.rb
111
+ - spec/spec_helper.rb
112
+ homepage: http://github.com/kaleworsley/omniauth-xero
113
+ licenses:
114
+ - MIT
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ required_rubygems_version: !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ! '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 1.8.23
134
+ signing_key:
135
+ specification_version: 3
136
+ summary: Xero authentication strategy for OmniAuth.
137
+ test_files:
138
+ - spec/omniauth/strategies/xero_spec.rb
139
+ - spec/spec_helper.rb