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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 710ce4b2631d068119df7df6a9fdd4f69c0b8ac9
4
- data.tar.gz: 1f9dd810e4b3078db3512405cce20808a0c52f73
3
+ metadata.gz: afed44e061a6b8add2141e57e0df78187b79e368
4
+ data.tar.gz: af818f5dd4c4a129d835887403c44315cb9e133e
5
5
  SHA512:
6
- metadata.gz: c59c29fcd624154635cf63c6dbb535b13f9e024b097f6ee5b168e9f62b50b106644d99c6b7b096d312bd3c70b6ed4941fa8474a249c1bcaf8cdbf2dccbc2f549
7
- data.tar.gz: 603725edf347e698a6957b36a4a4d1ddf44c8e62d3a59ea7c1050a2a82120036d7108728e1cbd73baa97e844441831ae9f75ed9b7f13cf37aa0e267ddc2b56b4
6
+ metadata.gz: 77fd0226d1aa626a4e82a9245fa1a5a8c6a86303f1deca4d46b5bc29bedf6571e2568737019e2361dd9c1fbe73f009037bfc9fe730a09a99080e87525322b89b
7
+ data.tar.gz: 0b7b546dcaa6f80dc4e25524b7c5cc65860860bb16466a3e65240ba0adff94f26f1062e7c7990985075500baa7114b423b6d6070521c5d5c5545ddadd2c837e2
@@ -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`
@@ -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'] || 'Invalid authorization code.'
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
- params[:code] = @code
79
- params[:redirect_uri] = @redirect_uri
80
- params[:grant_type] = :authorization_code
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
@@ -1,6 +1,7 @@
1
1
  module Yt
2
2
  class Auth
3
- # current version of gem
4
- VERSION = '0.2.2'
3
+ # @return [String] the SemVer-compatible gem version.
4
+ # @see http://semver.org
5
+ VERSION = '0.2.3'
5
6
  end
6
7
  end
@@ -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.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.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-05-31 00:00:00.000000000 Z
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.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.1
27
+ version: 0.1.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: jwt
30
30
  requirement: !ruby/object:Gem::Requirement