omniauth-thingiverse 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +1 -0
- data/lib/omniauth/strategies/thingiverse.rb +37 -0
- data/lib/omniauth-thingiverse/version.rb +5 -0
- data/lib/omniauth-thingiverse.rb +2 -0
- data/omniauth-thingiverse.gemspec +22 -0
- metadata +86 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Scott Ballantyne
|
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,26 @@
|
|
1
|
+
# OmniAuth Thingiverse
|
2
|
+
|
3
|
+
This gem contains the Thingiverse strategy for OmniAuth.
|
4
|
+
|
5
|
+
|
6
|
+
## Using This Strategy
|
7
|
+
|
8
|
+
First start by adding this gem to your Gemfile:
|
9
|
+
|
10
|
+
gem 'omniauth-thingiverse'
|
11
|
+
|
12
|
+
Next, tell OmniAuth about this provider. For a Rails app, your `config/initializers/omniauth.rb` file should look like this:
|
13
|
+
|
14
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
15
|
+
provider :thingiverse, "CONSUMER_KEY", "CONSUMER_SECRET"
|
16
|
+
end
|
17
|
+
|
18
|
+
Replace CONSUMER_KEY and CONSUMER_SECRET with the appropriate values you obtained from www.thingiverse.com/developers .
|
19
|
+
|
20
|
+
## Note on Patches/Pull Requests
|
21
|
+
|
22
|
+
- Fork the project.
|
23
|
+
- Make your feature addition or bug fix.
|
24
|
+
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
|
25
|
+
- 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)
|
26
|
+
- Send me a pull request. Bonus points for topic branches.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Thingiverse < OmniAuth::Strategies::OAuth2
|
6
|
+
option :client_options, {
|
7
|
+
:site => 'https://api.thingiverse.com/',
|
8
|
+
:authorize_url => '/login/oauth/authorize',
|
9
|
+
:token_url => '/login/oauth/access_token',
|
10
|
+
:token_method => :get
|
11
|
+
}
|
12
|
+
def request_phase
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
uid { raw_info['uid'] }
|
17
|
+
|
18
|
+
info do
|
19
|
+
{
|
20
|
+
"uid" => raw_info["id"],
|
21
|
+
"image"=>raw_info['thumbnail'],
|
22
|
+
'name' => raw_info['name'],
|
23
|
+
'urls' => {
|
24
|
+
'Thingiverse' => raw_info['url']
|
25
|
+
}
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def raw_info
|
30
|
+
@raw_info ||= MultiJson.decode(access_token.get("/users/me?access_token=#{@access_token.token}").body)
|
31
|
+
@raw_info
|
32
|
+
rescue ::Errno::ETIMEDOUT
|
33
|
+
raise ::Timeout::Error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-thingiverse/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "omniauth-thingiverse"
|
8
|
+
gem.version = Omniauth::Thingiverse::VERSION
|
9
|
+
gem.authors = ["Scott Ballantyne"]
|
10
|
+
gem.email = ["ussballantyne@gmail.com"]
|
11
|
+
gem.description = %q{omniauth adapter for thingiverse}
|
12
|
+
gem.summary = %q{omniauth adapter for thingiverse}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.add_dependency 'omniauth', '> 0'
|
16
|
+
gem.add_dependency 'omniauth-oauth2', '> 0'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-thingiverse
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Ballantyne
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-06 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>'
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '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: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: omniauth-oauth2
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>'
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
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'
|
46
|
+
description: omniauth adapter for thingiverse
|
47
|
+
email:
|
48
|
+
- ussballantyne@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- lib/omniauth-thingiverse.rb
|
59
|
+
- lib/omniauth-thingiverse/version.rb
|
60
|
+
- lib/omniauth/strategies/thingiverse.rb
|
61
|
+
- omniauth-thingiverse.gemspec
|
62
|
+
homepage: ''
|
63
|
+
licenses: []
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.25
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: omniauth adapter for thingiverse
|
86
|
+
test_files: []
|