omniauth-untappd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eaa0bf0ab2a94cb9d65e0a3a2ed7b321d45553f6
4
+ data.tar.gz: 9465866f51cc7bb4ccf5d23776e4b8eeb15f7e62
5
+ SHA512:
6
+ metadata.gz: a9a77fe24a68ac2da31379382c5cc89f0b61b69f4b907843048ce3c54090cfd7c526d69ba2dcaad38d81fecf72165962cf54558a30f5918845582296851b5ae5
7
+ data.tar.gz: 0ebf49fe5e7341d65f6a66fc795ae982ab31505c03ed72c6537f8155f6eb9637650cf26e45bd706566e14980910ae227138833305cc3b96670f8da0cdc3d458d
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .rvmrc
6
+ Gemfile.lock
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --format=progress
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Vitali Kulikou
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ # Omniauth::Untappd
2
+
3
+ [![Build Status](https://travis-ci.org/sabotatore/omniauth-untappd.png)](https://travis-ci.org/sabotatore/omniauth-untappd) [![Code Climate](https://codeclimate.com/github/sabotatore/omniauth-untappd.png)](https://codeclimate.com/github/sabotatore/omniauth-untappd)
4
+
5
+ Untappd OAuth2 Strategy for OmniAuth.
6
+
7
+ ## Installation
8
+
9
+ Add to your `Gemfile`:
10
+
11
+ gem 'omniauth-untappd', github: 'sabotatore/omniauth-untappd'
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ ## Usage
18
+
19
+ ### Rails
20
+
21
+ Add this to or create `config/initializers/omniauth.rb`:
22
+
23
+ ```ruby
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :untappd, ENV['UNTAPPD_KEY'], ENV['UNTAPPD_SECRET']
26
+ end
27
+ ```
28
+
29
+ See more details on the omniauth module: https://github.com/intridea/omniauth#readme
30
+
31
+ ## Supported Rubies
32
+
33
+ OmniAuth Untappd is tested under 1.9.2, 1.9.3 and 2.0.0
34
+
35
+ [![Build Status](https://travis-ci.org/sabotatore/omniauth-untappd.png)](https://travis-ci.org/sabotatore/omniauth-untappd)
36
+
37
+ ## License
38
+
39
+ Copyright (c) 2013 Vitali Kulikou
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
42
+ this software and associated documentation files (the "Software"), to deal in
43
+ the Software without restriction, including without limitation the rights to
44
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
45
+ the Software, and to permit persons to whom the Software is furnished to do so,
46
+ subject to the following conditions:
47
+
48
+ The above copyright notice and this permission notice shall be included in all
49
+ copies or substantial portions of the Software.
50
+
51
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
52
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
53
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
54
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
55
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
56
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ desc 'Default: run specs.'
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
@@ -0,0 +1,2 @@
1
+ require "omniauth-untappd/version"
2
+ require 'omniauth/strategies/untappd'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Untappd
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,80 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Untappd < OmniAuth::Strategies::OAuth2
6
+ option :name, 'untappd'
7
+ option :provider_ignores_state, true
8
+
9
+ option :client_options, {
10
+ site: 'https://untappd.com',
11
+ authorize_url: '/oauth/authenticate',
12
+ token_url: '/oauth/authorize',
13
+ token_method: :get
14
+ }
15
+
16
+ option :token_params, {
17
+ parse: :json
18
+ }
19
+
20
+ uid { raw_info['id'] }
21
+
22
+ info do
23
+ {
24
+ name: user_name,
25
+ email: raw_info['settings']['email_address'],
26
+ nickname: raw_info['user_name'],
27
+ first_name: raw_info['first_name'],
28
+ last_name: raw_info['last_name'],
29
+ location: raw_info['location'],
30
+ description: raw_info['bio'],
31
+ image: raw_info['user_avatar'],
32
+ urls: { 'Untappd' => raw_info['untappd_url'],
33
+ 'Website' => raw_info['url'] }
34
+ }
35
+ end
36
+
37
+ extra do
38
+ { raw_info: raw_info }
39
+ end
40
+
41
+ def client
42
+ ::OAuth2::UntappdClient.new(options.client_id, options.client_secret, deep_symbolize(options.client_options))
43
+ end
44
+
45
+ def authorize_params
46
+ options.authorize_params[:redirect_url] = callback_url
47
+ super
48
+ end
49
+
50
+ def token_params
51
+ options.token_params[:redirect_url] = callback_url
52
+ super
53
+ end
54
+
55
+ def raw_info
56
+ access_token.options[:mode] = :query
57
+ access_token.options[:param_name] = :access_token
58
+ @raw_info ||= access_token.get('http://api.untappd.com/v4/user/info').parsed['response']['user']
59
+ end
60
+
61
+ private
62
+
63
+ def user_name
64
+ "#{raw_info['first_name']} #{raw_info['last_name']}"
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ module OAuth2
71
+ class UntappdClient < OAuth2::Client
72
+ def get_token(params, access_token_opts={}, access_token_class = AccessToken)
73
+ opts = { raise_errors: options[:raise_errors], parse: params.delete(:parse), params: params }
74
+ response = request(options[:token_method], token_url, opts)
75
+ untappd_response = response.parsed['response']
76
+ raise Error.new(response) if options[:raise_errors] && !(untappd_response.is_a?(Hash) && untappd_response['access_token'])
77
+ access_token_class.from_hash(self, untappd_response.merge(access_token_opts))
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-untappd/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.add_dependency 'omniauth', '~> 1.0'
6
+
7
+ gem.authors = ["Vitali Kulikou"]
8
+ gem.email = ["sabotatore@gmail.com"]
9
+ gem.description = %q{Untappd OAuth2 Strategy for OmniAuth.}
10
+ gem.summary = %q{Untappd OAuth2 Strategy for OmniAuth.}
11
+ gem.homepage = "https://github.com/sabotatore/omniauth-untappd"
12
+ gem.license = "MIT"
13
+
14
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
15
+ gem.files = `git ls-files`.split("\n")
16
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ gem.name = "omniauth-untappd"
18
+ gem.require_paths = ["lib"]
19
+ gem.version = OmniAuth::Untappd::VERSION
20
+
21
+ gem.add_runtime_dependency 'omniauth-oauth2', '~> 1.1.0'
22
+ gem.add_runtime_dependency 'multi_json', '~> 1.0'
23
+
24
+ gem.add_development_dependency 'rspec', '~> 2.7'
25
+ gem.add_development_dependency 'rack-test'
26
+ gem.add_development_dependency 'webmock'
27
+ gem.add_development_dependency 'simplecov'
28
+ end
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Untappd do
4
+ subject(:strategy) { OmniAuth::Strategies::Untappd.new('client_id', 'client_secret') }
5
+
6
+ let(:parsed_response) {{ 'response' => {
7
+ 'user' => {
8
+ 'id' => '123',
9
+ 'first_name' => 'John',
10
+ 'last_name' => 'Doe',
11
+ 'user_name' => 'john_doe',
12
+ 'untappd_url' => 'http://untappd.com/user/john_doe',
13
+ 'settings' => {
14
+ 'email_address' => 'john@doe'
15
+ }
16
+ }
17
+ }}}
18
+
19
+ context 'options' do
20
+ subject(:options) { strategy.options }
21
+
22
+ its(:name) { should eql 'untappd' }
23
+ its(:provider_ignores_state) { should be_true }
24
+
25
+ context 'client options' do
26
+ subject { options.client_options }
27
+
28
+ its(:site) { should eql 'https://untappd.com' }
29
+ its(:authorize_url) { should eql '/oauth/authenticate' }
30
+ its(:token_url) { should eql '/oauth/authorize' }
31
+ its(:token_method) { should eql :get }
32
+ end
33
+
34
+ context 'token_params' do
35
+ subject { options.token_params }
36
+
37
+ its(:parse) { should eql :json }
38
+ end
39
+
40
+ end
41
+
42
+ context '#raw_info' do
43
+ subject { strategy.raw_info }
44
+ let(:access_token) { double('AccessToken', options: {}) }
45
+ let(:response) { double('Response', parsed: parsed_response) }
46
+ let(:user_info_url) { 'http://api.untappd.com/v4/user/info' }
47
+
48
+ before { strategy.stub(access_token: access_token) }
49
+ before { access_token.should_receive(:get).with(user_info_url).and_return(response) }
50
+
51
+ it { should eql(parsed_response['response']['user']) }
52
+
53
+ context '#uid' do
54
+ subject { strategy.uid }
55
+
56
+ it { should eql '123' }
57
+ end
58
+
59
+ context '#info' do
60
+ subject(:info) { strategy.info }
61
+
62
+ it { expect(info[:name]).to eql 'John Doe' }
63
+ it { expect(info[:nickname]).to eql 'john_doe' }
64
+ it { expect(info[:email]).to eql 'john@doe' }
65
+ it { expect(info[:urls]['Untappd']).to eql 'http://untappd.com/user/john_doe' }
66
+ end
67
+
68
+ context '#extra' do
69
+ it { expect(strategy.extra[:raw_info]).to eql strategy.raw_info }
70
+ end
71
+ end
72
+
73
+ context 'client' do
74
+ subject { strategy.client }
75
+
76
+ it { should be_a_kind_of OAuth2::UntappdClient }
77
+ end
78
+
79
+ end
@@ -0,0 +1,15 @@
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 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-untappd'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-untappd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vitali Kulikou
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: omniauth-oauth2
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: multi_json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Untappd OAuth2 Strategy for OmniAuth.
112
+ email:
113
+ - sabotatore@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - .travis.yml
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - lib/omniauth-untappd.rb
126
+ - lib/omniauth-untappd/version.rb
127
+ - lib/omniauth/strategies/untappd.rb
128
+ - omniauth-untappd.gemspec
129
+ - spec/omniauth/strategies/untappd_spec.rb
130
+ - spec/spec_helper.rb
131
+ homepage: https://github.com/sabotatore/omniauth-untappd
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - '>='
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.0.14
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Untappd OAuth2 Strategy for OmniAuth.
155
+ test_files: []