omniauth-fitbit 1.0.5 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/LICENSE.md +1 -1
- data/example/example.rb +1 -1
- data/lib/omniauth-fitbit/version.rb +1 -1
- data/lib/omniauth/strategies/fitbit.rb +24 -9
- data/omniauth-fitbit.gemspec +3 -3
- data/spec/omniauth/strategies/fitbit_spec.rb +48 -22
- data/spec/spec_helper.rb +1 -1
- metadata +17 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb284ea02707a038bb8bd523ff6da1cb3356a6f1
|
4
|
+
data.tar.gz: 481ccbf103390f616d3d089a471f827189ec3d92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7b369fd4ac9e5efafe5de271b83c5115cbaa81b10d00c7bf2107ed1fb5cdf11162b11beb90b0dab46de96cd5cd2341a536bb0e1d74b7511a11b578699b89f00a
|
7
|
+
data.tar.gz: f756527a776b7865a5bc6809318dab76a95f092e97f4861e399488f09c948c9e2d852c1dd5428d537e6223093c07d073b9466ee7496ef20d4a0810267588ffb8
|
data/Gemfile
CHANGED
data/LICENSE.md
CHANGED
data/example/example.rb
CHANGED
@@ -3,7 +3,7 @@ require 'omniauth-fitbit'
|
|
3
3
|
|
4
4
|
use Rack::Session::Cookie
|
5
5
|
use OmniAuth::Builder do
|
6
|
-
provider :fitbit, '
|
6
|
+
provider :fitbit, '', '', { :scope => 'profile', :redirect_uri => 'http://localhost:4567/auth/fitbit/callback' }
|
7
7
|
end
|
8
8
|
|
9
9
|
get '/' do
|
@@ -1,22 +1,37 @@
|
|
1
|
-
require 'omniauth'
|
2
|
-
require 'omniauth/strategies/oauth'
|
1
|
+
require 'omniauth-oauth2'
|
3
2
|
|
4
3
|
module OmniAuth
|
5
4
|
module Strategies
|
6
|
-
class Fitbit < OmniAuth::Strategies::
|
5
|
+
class Fitbit < OmniAuth::Strategies::OAuth2
|
7
6
|
|
8
7
|
option :name, "fitbit"
|
9
8
|
|
10
9
|
option :client_options, {
|
11
|
-
:site
|
12
|
-
:authorize_url
|
13
|
-
:
|
14
|
-
:access_token_path => '/oauth/access_token',
|
15
|
-
:authorize_path => '/oauth/authorize'
|
10
|
+
:site => 'https://api.fitbit.com',
|
11
|
+
:authorize_url => 'https://www.fitbit.com/oauth2/authorize',
|
12
|
+
:token_url => 'https://api.fitbit.com/oauth2/token'
|
16
13
|
}
|
17
14
|
|
15
|
+
option :response_type, 'code'
|
16
|
+
option :authorize_options, %i(scope response_type redirect_uri)
|
17
|
+
|
18
|
+
def build_access_token
|
19
|
+
options.token_params.merge!(:headers => {'Authorization' => basic_auth_header })
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def basic_auth_header
|
24
|
+
"Basic " + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
|
25
|
+
end
|
26
|
+
|
27
|
+
def query_string
|
28
|
+
# Using state and code params in the callback_url causes a mismatch with
|
29
|
+
# the value set in the fitbit application configuration, so we're skipping them
|
30
|
+
''
|
31
|
+
end
|
32
|
+
|
18
33
|
uid do
|
19
|
-
access_token.params['
|
34
|
+
access_token.params['user_id']
|
20
35
|
end
|
21
36
|
|
22
37
|
info do
|
data/omniauth-fitbit.gemspec
CHANGED
@@ -8,14 +8,14 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["TK Gospodinov"]
|
9
9
|
s.email = ["tk@gospodinov.net"]
|
10
10
|
s.homepage = "http://github.com/tkgospodinov/omniauth-fitbit"
|
11
|
-
s.summary = %q{OmniAuth strategy for Fitbit}
|
12
|
-
s.description = %q{OmniAuth strategy for Fitbit}
|
11
|
+
s.summary = %q{OmniAuth OAuth2 strategy for Fitbit}
|
12
|
+
s.description = %q{OmniAuth OAuth2 strategy for Fitbit}
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split($\)
|
15
15
|
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_runtime_dependency 'omniauth-
|
19
|
+
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.4'
|
20
20
|
s.add_runtime_dependency 'multi_xml'
|
21
21
|
end
|
@@ -5,40 +5,66 @@ describe "OmniAuth::Strategies::Fitbit" do
|
|
5
5
|
OmniAuth::Strategies::Fitbit.new(nil, @options || {})
|
6
6
|
end
|
7
7
|
|
8
|
+
describe 'response_type' do
|
9
|
+
it 'includes :code' do
|
10
|
+
expect(subject.options["response_type"]).to include('code')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'authorize_options' do
|
15
|
+
it 'includes :scope' do
|
16
|
+
expect(subject.options["authorize_options"]).to include(:scope)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'includes :response_type' do
|
20
|
+
expect(subject.options["authorize_options"]).to include(:response_type)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'includes :redirect_uri' do
|
24
|
+
expect(subject.options["authorize_options"]).to include(:redirect_uri)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
8
28
|
context 'client options' do
|
9
29
|
it 'has correct OAuth endpoint' do
|
10
|
-
subject.options.client_options.site.
|
30
|
+
expect(subject.options.client_options.site).to eq('https://api.fitbit.com')
|
11
31
|
end
|
12
32
|
|
13
|
-
it 'has correct
|
14
|
-
subject.options.client_options.
|
33
|
+
it 'has correct authorize url' do
|
34
|
+
expect(subject.options.client_options.authorize_url).to eq('https://www.fitbit.com/oauth2/authorize')
|
15
35
|
end
|
16
36
|
|
17
|
-
it 'has correct
|
18
|
-
subject.options.client_options.
|
37
|
+
it 'has correct token url' do
|
38
|
+
expect(subject.options.client_options.token_url).to eq('https://api.fitbit.com/oauth2/token')
|
19
39
|
end
|
40
|
+
end
|
20
41
|
|
21
|
-
|
22
|
-
|
42
|
+
context 'auth header' do
|
43
|
+
before :each do
|
44
|
+
subject.options.client_id = 'testclientid'
|
45
|
+
subject.options.client_secret = 'testclientsecret'
|
23
46
|
end
|
24
47
|
|
48
|
+
it 'returns the correct authorization header value' do
|
49
|
+
expect(subject.basic_auth_header).to eq('Basic ' + Base64.strict_encode64("testclientid:testclientsecret"))
|
50
|
+
end
|
25
51
|
end
|
26
52
|
|
27
53
|
context 'uid' do
|
28
54
|
before :each do
|
29
55
|
access_token = double('access_token')
|
30
|
-
access_token.
|
31
|
-
subject.
|
56
|
+
allow(access_token).to receive('params') { { 'user_id' => '123ABC' } }
|
57
|
+
allow(subject).to receive(:access_token) { access_token }
|
32
58
|
end
|
33
59
|
|
34
60
|
it 'returns the correct id from raw_info' do
|
35
|
-
subject.uid.
|
61
|
+
expect(subject.uid).to eq('123ABC')
|
36
62
|
end
|
37
63
|
end
|
38
64
|
|
39
65
|
context 'info' do
|
40
66
|
before :each do
|
41
|
-
subject.
|
67
|
+
allow(subject).to receive(:raw_info) {
|
42
68
|
{
|
43
69
|
"user" =>
|
44
70
|
{
|
@@ -60,45 +86,45 @@ describe "OmniAuth::Strategies::Fitbit" do
|
|
60
86
|
end
|
61
87
|
|
62
88
|
it 'returns the correct name from raw_info' do
|
63
|
-
subject.info[:name].
|
89
|
+
expect(subject.info[:name]).to eq("JD")
|
64
90
|
end
|
65
91
|
|
66
92
|
it 'returns the correct full name from raw_info' do
|
67
|
-
subject.info[:full_name].
|
93
|
+
expect(subject.info[:full_name]).to eq("John Doe")
|
68
94
|
end
|
69
95
|
|
70
96
|
it 'returns the correct display name from raw_info' do
|
71
|
-
subject.info[:display_name].
|
97
|
+
expect(subject.info[:display_name]).to eq("JD")
|
72
98
|
end
|
73
99
|
|
74
100
|
it 'returns the correct nickname from raw_info' do
|
75
|
-
subject.info[:nickname].
|
101
|
+
expect(subject.info[:nickname]).to eq("Johnnie")
|
76
102
|
end
|
77
103
|
|
78
104
|
it 'returns the correct gender from raw_info' do
|
79
|
-
subject.info[:gender].
|
105
|
+
expect(subject.info[:gender]).to eq("MALE")
|
80
106
|
end
|
81
107
|
|
82
108
|
it 'returns the correct gender from raw_info' do
|
83
|
-
subject.info[:about_me].
|
109
|
+
expect(subject.info[:about_me]).to eq("I live in Kansas City, MO")
|
84
110
|
end
|
85
111
|
|
86
112
|
it 'returns the correct gender from raw_info' do
|
87
|
-
subject.info[:city].
|
113
|
+
expect(subject.info[:city]).to eq("Kansas City")
|
88
114
|
end
|
89
115
|
|
90
116
|
it 'returns the correct gender from raw_info' do
|
91
|
-
subject.info[:state].
|
117
|
+
expect(subject.info[:state]).to eq("MO")
|
92
118
|
end
|
93
119
|
|
94
120
|
it 'returns the correct gender from raw_info' do
|
95
|
-
subject.info[:country].
|
121
|
+
expect(subject.info[:country]).to eq("US")
|
96
122
|
end
|
97
123
|
end
|
98
124
|
|
99
125
|
context 'dateOfBirth is empty' do
|
100
126
|
before :each do
|
101
|
-
subject.
|
127
|
+
allow(subject).to receive(:raw_info) {
|
102
128
|
{
|
103
129
|
"user" =>
|
104
130
|
{
|
@@ -109,7 +135,7 @@ describe "OmniAuth::Strategies::Fitbit" do
|
|
109
135
|
}
|
110
136
|
end
|
111
137
|
it 'when return nil' do
|
112
|
-
subject.info[:dob].
|
138
|
+
expect(subject.info[:dob]).to be_nil
|
113
139
|
end
|
114
140
|
end
|
115
141
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,56 +1,51 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-fitbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- TK Gospodinov
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: omniauth-
|
14
|
+
name: omniauth-oauth2
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '1.
|
19
|
+
version: '1.4'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '1.
|
26
|
+
version: '1.4'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: multi_xml
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
description: OmniAuth strategy for Fitbit
|
41
|
+
description: OmniAuth OAuth2 strategy for Fitbit
|
47
42
|
email:
|
48
43
|
- tk@gospodinov.net
|
49
44
|
executables: []
|
50
45
|
extensions: []
|
51
46
|
extra_rdoc_files: []
|
52
47
|
files:
|
53
|
-
- .gitignore
|
48
|
+
- ".gitignore"
|
54
49
|
- Gemfile
|
55
50
|
- LICENSE.md
|
56
51
|
- README.md
|
@@ -65,28 +60,27 @@ files:
|
|
65
60
|
- spec/spec_helper.rb
|
66
61
|
homepage: http://github.com/tkgospodinov/omniauth-fitbit
|
67
62
|
licenses: []
|
63
|
+
metadata: {}
|
68
64
|
post_install_message:
|
69
65
|
rdoc_options: []
|
70
66
|
require_paths:
|
71
67
|
- lib
|
72
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
69
|
requirements:
|
75
|
-
- -
|
70
|
+
- - ">="
|
76
71
|
- !ruby/object:Gem::Version
|
77
72
|
version: '0'
|
78
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
74
|
requirements:
|
81
|
-
- -
|
75
|
+
- - ">="
|
82
76
|
- !ruby/object:Gem::Version
|
83
77
|
version: '0'
|
84
78
|
requirements: []
|
85
79
|
rubyforge_project:
|
86
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.2.2
|
87
81
|
signing_key:
|
88
|
-
specification_version:
|
89
|
-
summary: OmniAuth strategy for Fitbit
|
82
|
+
specification_version: 4
|
83
|
+
summary: OmniAuth OAuth2 strategy for Fitbit
|
90
84
|
test_files:
|
91
85
|
- spec/omniauth/strategies/fitbit_spec.rb
|
92
86
|
- spec/spec_helper.rb
|