omniauth-lyft 1.0.0 → 1.0.1
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.
- checksums.yaml +4 -4
- data/lib/omniauth/lyft/version.rb +1 -1
- data/lib/omniauth/strategies/lyft.rb +31 -30
- data/spec/app.rb +1 -1
- data/spec/omniauth/strategies/lyft_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb92324268160dfb558ef9e14002d1a0e29203b5
|
4
|
+
data.tar.gz: 3fa3b1618d46c1e499bd29a6e99f11f5bd50ca51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e0b93d9cb43708edb57682092de2d2099c1fcc80f1275fc36f384452f8cd6265eb4dbf50ea736cf8ce03568497174e8ce71e8da849f37e7167fe86ff723676
|
7
|
+
data.tar.gz: d2a52d7c8290d055a39932db3a4415e86f95ef5dd92f60216477fa5cf539113656edc78a3d1b8c2cad076278f4289b1f790ad39468b95b8677cb0c9ed6ec58ec
|
@@ -1,45 +1,46 @@
|
|
1
1
|
require 'omniauth-oauth2'
|
2
2
|
|
3
|
+
# Shamelessly lifted from @rforgeon: https://github.com/rforgeon/dash-api/blob/master/lib/omniauth/strategies/lyft.rb
|
4
|
+
|
3
5
|
module OmniAuth
|
4
6
|
module Strategies
|
5
7
|
class Lyft < OmniAuth::Strategies::OAuth2
|
6
|
-
DEFAULT_SCOPE = 'profile'
|
7
|
-
|
8
|
-
option :client_options, :site => 'https://api.lyft.com',
|
9
|
-
:authorize_url => 'https://api.lyft.com/oauth/authorize',
|
10
|
-
:token_url => 'https://api.lyft.com/oauth/token'
|
11
|
-
|
12
|
-
uid { raw_info['uuid'] }
|
13
|
-
|
14
|
-
info do
|
15
|
-
{
|
16
|
-
:first_name => raw_info['first_name'],
|
17
|
-
:last_name => raw_info['last_name'],
|
18
|
-
:email => raw_info['email'],
|
19
|
-
:picture => raw_info['picture'],
|
20
|
-
:promo_code => raw_info['promo_code']
|
21
|
-
}
|
22
|
-
end
|
23
8
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
9
|
+
# Give your strategy a name.
|
10
|
+
option :name, "lyft"
|
11
|
+
|
12
|
+
# This is where you pass the options you would pass when
|
13
|
+
# initializing your consumer from the OAuth gem.
|
14
|
+
option :client_options, {
|
15
|
+
site: "https://api.lyft.com/v1",
|
16
|
+
authorize_url: "https://api.lyft.com/oauth/authorize?response_type=code",
|
17
|
+
token_url: 'https://api.lyft.com/oauth/token'
|
18
|
+
}
|
19
|
+
|
20
|
+
option :authorize_options, [:scope]
|
21
|
+
|
22
|
+
option :token_params, :grant_type => 'authorization_code'
|
23
|
+
|
24
|
+
# These are called after authentication has succeeded. If
|
25
|
+
# possible, you should try to set the UID without making
|
26
|
+
# additional calls (if the user id is returned with the token
|
27
|
+
# or as a URI parameter). This may not be possible with all
|
28
|
+
# providers.
|
29
|
+
|
29
30
|
|
30
31
|
def raw_info
|
31
|
-
@raw_info ||= access_token.get(
|
32
|
+
@raw_info ||= access_token.get("#{options[:client_options][:site]}/profile").parsed
|
32
33
|
end
|
33
34
|
|
34
|
-
def
|
35
|
-
options[
|
36
|
-
:client_id => options['client_id'],
|
37
|
-
:response_type => 'code',
|
38
|
-
:scopes => (options['scope'] || DEFAULT_SCOPE)
|
39
|
-
}
|
40
|
-
|
35
|
+
def build_access_token
|
36
|
+
options.token_params.merge!(:code => request.params["code"], :headers => {'Authorization' => basic_auth_header })
|
41
37
|
super
|
42
38
|
end
|
39
|
+
|
40
|
+
def basic_auth_header
|
41
|
+
"Basic " + Base64.strict_encode64("#{options[:client_id]}:#{options[:client_secret]}")
|
42
|
+
end
|
43
|
+
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
data/spec/app.rb
CHANGED
@@ -11,7 +11,7 @@ Dotenv.load
|
|
11
11
|
enable :sessions
|
12
12
|
|
13
13
|
use OmniAuth::Builder do
|
14
|
-
provider :lyft,
|
14
|
+
provider :lyft, 'raJvYFp-ZFhN', 'wRqziw1FYxz2iiL22i7d3HKe3p4qazSh', :scope => 'profile rides.request'
|
15
15
|
end
|
16
16
|
|
17
17
|
get '/' do
|
@@ -15,11 +15,11 @@ describe OmniAuth::Strategies::Lyft do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should have correct site' do
|
18
|
-
expect(subject.options.client_options.site).to eq('https://api.lyft.com')
|
18
|
+
expect(subject.options.client_options.site).to eq('https://api.lyft.com/v1')
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should have correct authorize url' do
|
22
|
-
expect(subject.options.client_options.authorize_url).to eq('https://api.lyft.com/oauth/authorize')
|
22
|
+
expect(subject.options.client_options.authorize_url).to eq('https://api.lyft.com/oauth/authorize?response_type=code')
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should have correct access token url' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-lyft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|