omniauth-etsy 0.0.1.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ .DS_Store
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ testapp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-etsy.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Jeff Mehlhoff
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,40 @@
1
+ # Omniauth::Etsy
2
+
3
+ A (very alpha) unofficial OmniAuth strategy for Etsy. You'll need to register an application on Etsy (https://www.etsy.com/developers/register) to get a token and secret.
4
+
5
+ ## Useage
6
+
7
+ Rails.application.config.middleware.use OmniAuth::Builder do
8
+ provider :etsy, 'token', 'secret'
9
+ end
10
+
11
+ Optionally, you may pass in comma separated "Permission Scopes" (http://www.etsy.com/developers/documentation/getting_started/oauth#section_permission_scopes)
12
+
13
+
14
+ Rails.application.config.middleware.use OmniAuth::Builder do
15
+ provider :etsy, 'token', 'secret', :scope => 'email_r,listings_r'
16
+ end
17
+
18
+
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ gem 'omniauth-etsy', '0.0.1-alpha'
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install omniauth-etsy
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,58 @@
1
+ require 'omniauth-oauth'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Etsy < OmniAuth::Strategies::OAuth
6
+ option :client_options, {
7
+ :site => "http://sandbox.openapi.etsy.com/v2",
8
+ :request_token_path => "/oauth/request_token",
9
+ :access_token_path => "/oauth/access_token",
10
+ :authorize_url => "https://www.etsy.com/oauth/signin"
11
+ }
12
+
13
+ uid { user_hash['user_id'] }
14
+
15
+ info do
16
+ {
17
+ 'nickname' => raw_info['login_name'],
18
+ 'email' => raw_info['primary_email'],
19
+ 'user_id' => raw_info['user_id'],
20
+ }.merge!(profile_info)
21
+ end
22
+
23
+ def request_phase
24
+ if options.scope
25
+ options.request_params.merge!(:scope => Rack::Utils.build_query(options.scope))
26
+ end
27
+ super
28
+ end
29
+
30
+ def profile_info
31
+ profile = user_hash['Profile']
32
+ if profile
33
+ {
34
+ 'first_name' => profile['first_name'],
35
+ 'last_name' => profile['last_name'],
36
+ 'image' => profile['image_url_75x75'],
37
+ 'full_name' => "#{profile['first_name']} #{profile['last_name']}"
38
+ }
39
+ else
40
+ {}
41
+ end
42
+ end
43
+
44
+ def raw_info
45
+ @data ||= user_hash
46
+ end
47
+
48
+ def user_hash
49
+ @user_hash ||= MultiJson.decode(@access_token.get('/users/__SELF__?includes=Profile').body)['results'][0]
50
+ rescue ::Errno::ETIMEDOUT
51
+ raise ::Timeout::Error
52
+ rescue ::OAuth::Error => e
53
+ raise e.response.inspect
54
+ end
55
+
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Etsy
3
+ VERSION = "0.0.1.alpha"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-etsy/version"
2
+ require "omniauth/strategies/etsy"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-etsy/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Jeff Mehlhoff"]
6
+ gem.email = ["jeffmehlhoff@mac.com"]
7
+ gem.description = %q{OmniAuth strategy for Etsy}
8
+ gem.summary = %q{OmniAuth strategy for Etsy}
9
+ gem.homepage = "http://github.com/ohokay/omniauth-etsy"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "omniauth-etsy"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Omniauth::Etsy::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth', '~> 1.0'
20
+ gem.add_dependency 'multi_json'
21
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-etsy
3
+ version: !ruby/object:Gem::Version
4
+ hash: -829619701
5
+ prerelease: 6
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ - alpha
11
+ version: 0.0.1.alpha
12
+ platform: ruby
13
+ authors:
14
+ - Jeff Mehlhoff
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2012-05-18 00:00:00 -07:00
20
+ default_executable:
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: omniauth
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 15
31
+ segments:
32
+ - 1
33
+ - 0
34
+ version: "1.0"
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: omniauth-oauth
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 15
46
+ segments:
47
+ - 1
48
+ - 0
49
+ version: "1.0"
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: multi_json
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ type: :runtime
65
+ version_requirements: *id003
66
+ description: OmniAuth strategy for Etsy
67
+ email:
68
+ - jeffmehlhoff@mac.com
69
+ executables: []
70
+
71
+ extensions: []
72
+
73
+ extra_rdoc_files: []
74
+
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE
79
+ - README.md
80
+ - Rakefile
81
+ - lib/omniauth-etsy.rb
82
+ - lib/omniauth-etsy/version.rb
83
+ - lib/omniauth/strategies/etsy.rb
84
+ - omniauth-etsy.gemspec
85
+ has_rdoc: true
86
+ homepage: http://github.com/ohokay/omniauth-etsy
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options: []
91
+
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">"
107
+ - !ruby/object:Gem::Version
108
+ hash: 25
109
+ segments:
110
+ - 1
111
+ - 3
112
+ - 1
113
+ version: 1.3.1
114
+ requirements: []
115
+
116
+ rubyforge_project:
117
+ rubygems_version: 1.6.2
118
+ signing_key:
119
+ specification_version: 3
120
+ summary: OmniAuth strategy for Etsy
121
+ test_files: []
122
+