yt-auth 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/yt/auth.rb +19 -4
- data/lib/yt/auth/version.rb +3 -2
- data/yt-auth.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: afed44e061a6b8add2141e57e0df78187b79e368
|
4
|
+
data.tar.gz: af818f5dd4c4a129d835887403c44315cb9e133e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77fd0226d1aa626a4e82a9245fa1a5a8c6a86303f1deca4d46b5bc29bedf6571e2568737019e2361dd9c1fbe73f009037bfc9fe730a09a99080e87525322b89b
|
7
|
+
data.tar.gz: 0b7b546dcaa6f80dc4e25524b7c5cc65860860bb16466a3e65240ba0adff94f26f1062e7c7990985075500baa7114b423b6d6070521c5d5c5545ddadd2c837e2
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,10 @@ For more information about changelogs, check
|
|
6
6
|
[Keep a Changelog](http://keepachangelog.com) and
|
7
7
|
[Vandamme](http://tech-angels.github.io/vandamme).
|
8
8
|
|
9
|
+
## 0.2.3 - 2017-08-24
|
10
|
+
|
11
|
+
* [FEATURE] Add the ability to generate access token from a refresh token
|
12
|
+
|
9
13
|
## 0.2.2 - 2017-05-31
|
10
14
|
|
11
15
|
* [FEATURE] Add `Auth#access_token`
|
data/lib/yt/auth.rb
CHANGED
@@ -16,6 +16,7 @@ module Yt
|
|
16
16
|
def initialize(options = {})
|
17
17
|
@redirect_uri = options[:redirect_uri]
|
18
18
|
@code = options[:code]
|
19
|
+
@refresh_token = options[:refresh_token]
|
19
20
|
end
|
20
21
|
|
21
22
|
# @return [String] the URL where to authenticate with a Google account.
|
@@ -42,6 +43,7 @@ module Yt
|
|
42
43
|
{}.tap do |params|
|
43
44
|
params[:client_id] = Yt.configuration.client_id
|
44
45
|
params[:scope] = :email
|
46
|
+
params[:access_type] = :offline
|
45
47
|
params[:redirect_uri] = @redirect_uri
|
46
48
|
params[:response_type] = :code
|
47
49
|
end
|
@@ -66,7 +68,7 @@ module Yt
|
|
66
68
|
params[:request_format] = :form
|
67
69
|
params[:body] = tokens_body
|
68
70
|
params[:error_message] = ->(body) {
|
69
|
-
JSON(body)['error_description'] ||
|
71
|
+
JSON(body)['error_description'] || token_error_message
|
70
72
|
}
|
71
73
|
end
|
72
74
|
end
|
@@ -75,9 +77,22 @@ module Yt
|
|
75
77
|
{}.tap do |params|
|
76
78
|
params[:client_id] = Yt.configuration.client_id
|
77
79
|
params[:client_secret] = Yt.configuration.client_secret
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
if @refresh_token
|
81
|
+
params[:refresh_token] = @refresh_token
|
82
|
+
params[:grant_type] = :refresh_token
|
83
|
+
else
|
84
|
+
params[:code] = @code
|
85
|
+
params[:redirect_uri] = @redirect_uri
|
86
|
+
params[:grant_type] = :authorization_code
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def token_error_message
|
92
|
+
if @refresh_token
|
93
|
+
'Invalid refresh token.'
|
94
|
+
else
|
95
|
+
'Invalid authorization code.'
|
81
96
|
end
|
82
97
|
end
|
83
98
|
end
|
data/lib/yt/auth/version.rb
CHANGED
data/yt-auth.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
25
|
spec.require_paths = ['lib']
|
26
26
|
|
27
|
-
spec.add_dependency 'yt-support', '>= 0.1.
|
27
|
+
spec.add_dependency 'yt-support', '>= 0.1.3'
|
28
28
|
spec.add_dependency 'jwt', '>= 1.5.6'
|
29
29
|
|
30
30
|
spec.add_development_dependency 'bundler', '~> 1.14'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yt-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claudio Baccigalupo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yt-support
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.1.
|
20
|
+
version: 0.1.3
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.1.
|
27
|
+
version: 0.1.3
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: jwt
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|