omniauth-jawbone 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +12 -0
- data/Guardfile +10 -0
- data/LICENSE.txt +0 -0
- data/README.md +32 -0
- data/Rakefile +12 -0
- data/lib/omniauth/strategies/jawbone-attempt2.rb +0 -0
- data/lib/omniauth/strategies/jawbone.rb +151 -0
- data/lib/omniauth-jawbone/version.rb +5 -0
- data/lib/omniauth-jawbone.rb +2 -0
- data/omniauth-jawbone.gemspec +24 -0
- data/spec/omniauth/strategies/jawbone_spec.rb +26 -0
- data/spec/spec_helper.rb +16 -0
- metadata +160 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# OmniAuth Jawbone
|
2
|
+
|
3
|
+
This is the unofficial OmniAuth strategy for authenticating to Jawbone. To
|
4
|
+
use it, you'll need to sign up for an OAuth2 Application ID and Secret
|
5
|
+
once Jawbone releases their public API.
|
6
|
+
|
7
|
+
## Basic Usage
|
8
|
+
|
9
|
+
use OmniAuth::Builder do
|
10
|
+
provider :jawbone, ENV['JAWBONE_CLIENT_ID'], ENV['JAWBONE_CLIENT_SECRET']
|
11
|
+
end
|
12
|
+
|
13
|
+
## License
|
14
|
+
|
15
|
+
Copyright (c) 2011 Jacques Crocker
|
16
|
+
|
17
|
+
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:
|
18
|
+
|
19
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
20
|
+
|
21
|
+
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.
|
22
|
+
|
23
|
+
|
24
|
+
## Original License
|
25
|
+
|
26
|
+
Copyright (c) 2011 Michael Bleigh and Intridea, Inc.
|
27
|
+
|
28
|
+
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:
|
29
|
+
|
30
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
31
|
+
|
32
|
+
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.
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
require 'uri'
|
3
|
+
require 'oauth2'
|
4
|
+
require 'omniauth'
|
5
|
+
require 'timeout'
|
6
|
+
require 'securerandom'
|
7
|
+
require 'omniauth-oauth2'
|
8
|
+
|
9
|
+
module OmniAuth
|
10
|
+
module Strategies
|
11
|
+
# Authentication strategy for connecting with APIs constructed using
|
12
|
+
# the [OAuth 2.0 Specification](http://tools.ietf.org/html/draft-ietf-oauth-v2-10).
|
13
|
+
# You must generally register your application with the provider and
|
14
|
+
# utilize an application id and secret in order to authenticate using
|
15
|
+
# OAuth 2.0.
|
16
|
+
class Jawbone
|
17
|
+
include OmniAuth::Strategy
|
18
|
+
|
19
|
+
# def initialize(app, client_id = nil, client_secret = nil, options = {}, &block)
|
20
|
+
#option :client_options,
|
21
|
+
#opts = {
|
22
|
+
option :client_options, {
|
23
|
+
:site => 'https://jawbone.com',
|
24
|
+
:authorize_url => '/auth/oauth2/auth',
|
25
|
+
:token_url => '/auth/oauth2/token'
|
26
|
+
}
|
27
|
+
#super(app, :jawbone, client_id, client_secret, opts, options, &block)
|
28
|
+
# end
|
29
|
+
|
30
|
+
# def request_phase
|
31
|
+
# super
|
32
|
+
# end
|
33
|
+
|
34
|
+
|
35
|
+
def authorize_params
|
36
|
+
super.tap do |params|
|
37
|
+
%w[scope client_options].each do |v|
|
38
|
+
if request.params[v]
|
39
|
+
params[v.to_sym] = request.params[v]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
uid { raw_info['id'].to_s }
|
46
|
+
|
47
|
+
info do
|
48
|
+
{
|
49
|
+
'xid' => raw_info['xid'],
|
50
|
+
'photo' => raw_info['photo'],
|
51
|
+
'first_name' => raw_info['first'],
|
52
|
+
'last_name' => raw_info['last'],
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
extra do
|
57
|
+
{:raw_info => raw_info}
|
58
|
+
end
|
59
|
+
|
60
|
+
def raw_info
|
61
|
+
access_token.options[:mode] = :query
|
62
|
+
@raw_info ||= access_token.get('user').parsed
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def user_data
|
67
|
+
access_token.options[:mode] = :query
|
68
|
+
user_data ||= access_token.get('/nudge/api/users/@me').parsed
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
OmniAuth.config.add_camelization 'jawbone', 'Jawbone'
|
77
|
+
|
78
|
+
# option :client_options, {
|
79
|
+
# :site => 'https://jawbone.com',
|
80
|
+
# :authorize_url => '/auth/oauth2/auth',
|
81
|
+
# :token_url => '/auth/oauth2/token'
|
82
|
+
# }
|
83
|
+
|
84
|
+
|
85
|
+
# def client
|
86
|
+
# ::OAuth2::Client.new(ENV["CLIENT_ID"], ENV["CLIENT_SECRET"], :site => 'https://jawbone.com', :authorize_url => '/auth/oauth2/auth', :token_url => '/auth/oauth2/token')
|
87
|
+
# end
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
# # def request_phase
|
92
|
+
# # Omniauth::Form.build url:callback_url do
|
93
|
+
# # #text_field 'client_id', 'ENV["CLIENT_ID"]'
|
94
|
+
# # text_field 'response_type', 'code'
|
95
|
+
# # text_field 'scope', 'basic_read sleep_read'
|
96
|
+
# # text_field 'redirect_uri', "http://www.gitsleep.com/auth"
|
97
|
+
# # end
|
98
|
+
# # end
|
99
|
+
|
100
|
+
# # def self.temporary_code_to_token(code)
|
101
|
+
# # json = HTTParty.post(
|
102
|
+
# # "https://jawbone.com/auth/oauth2/token",
|
103
|
+
# # :body => {
|
104
|
+
# # :client_id => ENV["CLIENT_ID"],
|
105
|
+
# # :client_secret => ENV["CLIENT_SECRET"],
|
106
|
+
# # :grant_type => "authorization_code",
|
107
|
+
# # :code => code
|
108
|
+
# # }
|
109
|
+
# # ).body
|
110
|
+
# # return JSON.parse(json)["access_token"]
|
111
|
+
# # end
|
112
|
+
|
113
|
+
# # def self.token_to_user_info(token)
|
114
|
+
# # HTTParty.get(
|
115
|
+
# # "https://jawbone.com/nudge/api/users/@me",
|
116
|
+
# # :headers => {
|
117
|
+
# # "Authorization" => "Bearer #{token}"
|
118
|
+
# # }
|
119
|
+
# # )["data"]
|
120
|
+
# # end
|
121
|
+
|
122
|
+
# credentials do
|
123
|
+
|
124
|
+
# hash = {'token' => access_token.token}
|
125
|
+
# hash.merge!('refresh_token' => access_token.refresh_token) if access_token.expires? && access_token.refresh_token
|
126
|
+
# hash.merge!('expires_at' => access_token.expires_at) if access_token.expires?
|
127
|
+
# hash.merge!('expires' => access_token.expires?)
|
128
|
+
# hash
|
129
|
+
# end
|
130
|
+
|
131
|
+
|
132
|
+
# def user_data
|
133
|
+
# access_token.options[:mode] = :query
|
134
|
+
# user_data ||= access_token.get('/nudge/api/users/@me').parsed
|
135
|
+
# end
|
136
|
+
|
137
|
+
# end
|
138
|
+
# end
|
139
|
+
# end
|
140
|
+
|
141
|
+
|
142
|
+
# uid { user_data['xid'] }
|
143
|
+
|
144
|
+
# info do
|
145
|
+
# {
|
146
|
+
# token = token
|
147
|
+
# photo = user_info["image"]
|
148
|
+
# first_name = user_info["first"]
|
149
|
+
# last_name = user_info["last"]
|
150
|
+
# }
|
151
|
+
# end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth-jawbone/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Ruthie Nachmany", "Max Jacobson", "Sarah Duve"]
|
6
|
+
gem.email = ["ruthie.nachmany@flatironschool.com", "maxwell.jacobson@flatironschool.com", "sarah.duve@flatironschool.com"]
|
7
|
+
gem.description = %q{OmniAuth strategy for Jawbone.}
|
8
|
+
gem.summary = %q{OmniAuth strategy for Jawbone.}
|
9
|
+
gem.homepage = "https://github.com/railsjedi/omniauth-jawbone"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "omniauth-jawbone"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = OmniAuth::Jawbone::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'omniauth', '~> 1.0'
|
19
|
+
gem.add_dependency 'omniauth-oauth2', '~> 1.0'
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
21
|
+
gem.add_development_dependency 'rack-test'
|
22
|
+
gem.add_development_dependency 'simplecov'
|
23
|
+
gem.add_development_dependency 'webmock'
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative '../../../lib/omniauth/strategies/jawbone'
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::Jawbone do
|
5
|
+
subject do
|
6
|
+
OmniAuth::Strategies::Jawbone.new({})
|
7
|
+
end
|
8
|
+
|
9
|
+
context "client options" do
|
10
|
+
it "should have correct site" do
|
11
|
+
subject.options.client_options.site.should eq("https://jawbone.com")
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have correct authorize path" do
|
15
|
+
subject.options.client_options.authorize_path.should eq("/auth/oauth2/auth")
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have the correct request token path" do
|
19
|
+
subject.options.client_options.request_token_path.should eq("/auth/oauth2/token)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have the correct access token path" do
|
23
|
+
subject.options.client_options.access_token_path.should eq("/1/OAuthGetAccessToken")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
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-jawbone'
|
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
|
16
|
+
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-jawbone
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.32
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ruthie Nachmany
|
9
|
+
- Max Jacobson
|
10
|
+
- Sarah Duve
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2013-08-15 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: omniauth
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '1.0'
|
24
|
+
type: :runtime
|
25
|
+
prerelease: false
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
none: false
|
28
|
+
requirements:
|
29
|
+
- - ~>
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '1.0'
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: omniauth-oauth2
|
34
|
+
requirement: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ~>
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: rspec
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '2.7'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ~>
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.7'
|
64
|
+
- !ruby/object:Gem::Dependency
|
65
|
+
name: rack-test
|
66
|
+
requirement: !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ! '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
type: :development
|
73
|
+
prerelease: false
|
74
|
+
version_requirements: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov
|
82
|
+
requirement: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: webmock
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
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
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
description: OmniAuth strategy for Jawbone.
|
113
|
+
email:
|
114
|
+
- ruthie.nachmany@flatironschool.com
|
115
|
+
- maxwell.jacobson@flatironschool.com
|
116
|
+
- sarah.duve@flatironschool.com
|
117
|
+
executables: []
|
118
|
+
extensions: []
|
119
|
+
extra_rdoc_files: []
|
120
|
+
files:
|
121
|
+
- .gitignore
|
122
|
+
- Gemfile
|
123
|
+
- Guardfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- lib/omniauth-jawbone.rb
|
128
|
+
- lib/omniauth-jawbone/version.rb
|
129
|
+
- lib/omniauth/strategies/jawbone-attempt2.rb
|
130
|
+
- lib/omniauth/strategies/jawbone.rb
|
131
|
+
- omniauth-jawbone.gemspec
|
132
|
+
- spec/omniauth/strategies/jawbone_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: https://github.com/railsjedi/omniauth-jawbone
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 1.8.25
|
155
|
+
signing_key:
|
156
|
+
specification_version: 3
|
157
|
+
summary: OmniAuth strategy for Jawbone.
|
158
|
+
test_files:
|
159
|
+
- spec/omniauth/strategies/jawbone_spec.rb
|
160
|
+
- spec/spec_helper.rb
|