google-ads-common 0.12.6 → 0.13.0

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: a4310819d97635131655a65b5d98849c18ec76cb
4
- data.tar.gz: 63c393bcacd43a3c34763f12c8ec939499dac628
3
+ metadata.gz: 2f9fd925b1012604aaedfaba55ac60cd16fed3f3
4
+ data.tar.gz: 4a27eb4e56b52c99148be41fdcfc98946a9fd947
5
5
  SHA512:
6
- metadata.gz: dfc0517f0ad20ba3a4a2e39a7cb11ad711364c67def32b6833adbc873fbad27e994cd96c1b99005589c53cec604c4d28671e540a398a894c387a266c382c2800
7
- data.tar.gz: 3ac22c22c57f716fa0e5dd822668d24e5c42c03f3cd6e5030650f88d701f2fea3a326f8adf4afd447dded0655c5ccd0280cba4f078b0296c95d76d7241b565b2
6
+ metadata.gz: 1664c58b1bae120d33c4d890d4978c0702cd9caa65dffa39d146a985a42985df7bef92b93447d0c25f9a7158991f5371dce495943f2bc5f61bae5276081bb979
7
+ data.tar.gz: 71d90e5d480d8f17457261c13f8e61e2e573a72e27d42b1101fa8ba518fbcc920c75fa4fbed9fd3b285845305666e802f8721d6b9889a84de9def2a6e18b3b4d
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ 0.13.0:
2
+ - Removed support for p12 keyfiles for service accounts.
3
+ - Fixed issue #27. You can now force a refresh when fetching the access token
4
+ using the get_token function.
5
+
1
6
  0.12.6:
2
7
  - Added support for config param :oauth2_prompt and removed support for
3
8
  :oauth2_approval_prompt, and updated URI parameter name. The expected value
@@ -82,9 +82,10 @@ module AdsCommon
82
82
  end
83
83
 
84
84
  # Overrides base get_token method to account for the token expiration.
85
- def get_token(credentials = nil)
85
+ def get_token(credentials = nil, force_refresh = false)
86
86
  token = super(credentials)
87
- token = refresh_token! if !@client.nil? && @client.expired?
87
+ token = refresh_token! if !@client.nil? &&
88
+ (force_refresh || @client.expired?)
88
89
  return token
89
90
  end
90
91
 
@@ -124,30 +124,20 @@ module AdsCommon
124
124
  'key file provided, only one can be used.'
125
125
  end
126
126
 
127
- p12 = true
128
127
  if credentials[:oauth2_keyfile]
129
128
  file_name = credentials[:oauth2_keyfile]
130
129
  if File.file?(file_name)
131
- unless file_name.end_with?('.p12') || file_name.end_with?('.json')
130
+ unless file_name.end_with?('.json')
132
131
  raise AdsCommon::Errors::AuthError,
133
- "Key file '%s' must be either a .p12 or .json file." %
134
- file_name
132
+ "Key file '%s' must be a .json file." % file_name
135
133
  end
136
- p12 = false if file_name.end_with?('.json')
137
134
  else
138
135
  raise AdsCommon::Errors::AuthError,
139
136
  "Key file '%s' does not exist or not a file." % file_name
140
137
  end
141
- end
142
-
143
- if credentials[:oauth2_issuer].nil? && p12
144
- raise AdsCommon::Errors::AuthError,
145
- 'Issuer is not included in the credentials.'
146
- end
147
-
148
- if credentials[:oauth2_secret].nil? && p12
138
+ elsif credentials[:oauth2_issuer].nil?
149
139
  raise AdsCommon::Errors::AuthError,
150
- 'Key secret is not included in the credentials.'
140
+ 'Issuer must be specified in the config if not using a key file.'
151
141
  end
152
142
 
153
143
  if credentials[:oauth2_key] &&
@@ -195,16 +185,9 @@ module AdsCommon
195
185
  def load_oauth2_service_account_credentials(credentials)
196
186
  return credentials unless credentials.include?(:oauth2_keyfile)
197
187
  key_file = File.read(credentials[:oauth2_keyfile])
198
- key = nil
199
- issuer = nil
200
- if credentials[:oauth2_keyfile].end_with?('.p12')
201
- key_secret = credentials[:oauth2_secret]
202
- key = OpenSSL::PKCS12.new(key_file, key_secret).key
203
- else
204
- key_file_hash = JSON.parse(key_file, :symbolize_names => true)
205
- key = OpenSSL::PKey::RSA.new(key_file_hash[:private_key])
206
- issuer = key_file_hash[:client_email]
207
- end
188
+ key_file_hash = JSON.parse(key_file, :symbolize_names => true)
189
+ key = OpenSSL::PKey::RSA.new(key_file_hash[:private_key])
190
+ issuer = key_file_hash[:client_email]
208
191
  result = credentials.merge({:oauth2_key => key})
209
192
  result[:oauth2_issuer] = issuer unless issuer.nil?
210
193
  result.delete(:oauth2_keyfile)
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- # Code template generator base class
18
+ # Code template generator base class.
19
19
 
20
20
  require 'ads_savon'
21
21
  require 'erb'
@@ -53,6 +53,7 @@ module AdsCommon
53
53
  @modules_open_string = 'module ' +
54
54
  [@api_name, @version.to_s.upcase, @service_name].join('; module ')
55
55
  @modules_close_string = 'end; end; end'
56
+ @year = Time.now.year
56
57
  end
57
58
 
58
59
  def remove_lines_with_blanks_only(text)
@@ -15,11 +15,12 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- # Code template for registry generation for Savon backend
18
+ # Code template for registry generation for Savon backend.
19
+
20
+ require 'pp'
19
21
 
20
22
  require 'ads_savon'
21
23
  require 'ads_common/build/savon_abstract_generator'
22
- require 'pp'
23
24
 
24
25
  module AdsCommon
25
26
  module Build
@@ -29,7 +30,7 @@ module AdsCommon
29
30
  #
30
31
  # This is auto-generated code, changes will be overwritten.
31
32
  #
32
- # Copyright:: Copyright 2016, Google Inc. All Rights Reserved.
33
+ # Copyright:: Copyright <%= @year %>, Google Inc. All Rights Reserved.
33
34
  # License:: Licensed under the Apache License, Version 2.0.
34
35
  #
35
36
  # <%= @generator_stamp %>
@@ -15,7 +15,7 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
- # Code template for wrappers generation for Savon backend
18
+ # Code template for wrappers generation for Savon backend.
19
19
 
20
20
  require 'ads_savon'
21
21
  require 'ads_common/build/savon_abstract_generator'
@@ -29,7 +29,7 @@ module AdsCommon
29
29
  #
30
30
  # This is auto-generated code, changes will be overwritten.
31
31
  #
32
- # Copyright:: Copyright 2016, Google Inc. All Rights Reserved.
32
+ # Copyright:: Copyright <%= @year %>, Google Inc. All Rights Reserved.
33
33
  # License:: Licensed under the Apache License, Version 2.0.
34
34
  #
35
35
  # <%= @generator_stamp %>
@@ -19,6 +19,6 @@
19
19
 
20
20
  module AdsCommon
21
21
  module ApiConfig
22
- CLIENT_LIB_VERSION = '0.12.6'
22
+ CLIENT_LIB_VERSION = '0.13.0'
23
23
  end
24
24
  end
@@ -36,7 +36,7 @@ class TestOAuthServiceAccount < Test::Unit::TestCase
36
36
  assert_nothing_raised do
37
37
  validate_credentials(['test', '.json'])
38
38
  end
39
- assert_nothing_raised do
39
+ assert_raise(AdsCommon::Errors::AuthError) do
40
40
  validate_credentials(['test', '.p12'])
41
41
  end
42
42
  assert_raises(AdsCommon::Errors::AuthError) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-ads-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.6
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Gomes
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-12-07 00:00:00.000000000 Z
13
+ date: 2017-03-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: google-ads-savon