signet 0.4.5 → 0.5.0

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.
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'addressable', '>= 2.3.1'
4
- gem 'faraday', '~> 0.8.1'
4
+ gem 'faraday', '>= 0.9.0.rc5'
5
5
  gem 'multi_json', '>= 1.0.0'
6
6
  gem 'jwt', '>= 0.1.5'
7
7
  gem 'extlib', '>= 0.9.15'
@@ -15,6 +15,7 @@ end
15
15
 
16
16
 
17
17
  group :test, :development do
18
+ gem 'json', '~> 1.7.7'
18
19
  gem 'rake', '>= 0.9.0'
19
20
  gem 'rspec', '>= 2.11.0'
20
21
  gem 'rcov', '>= 0.9.9', :platform => :mri_18
@@ -1,48 +1,40 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- addressable (2.3.2)
5
- bouncy-castle-java (1.5.0146.1)
6
- diff-lcs (1.1.3)
4
+ addressable (2.3.4)
5
+ diff-lcs (1.2.4)
7
6
  extlib (0.9.16)
8
- faraday (0.8.4)
7
+ faraday (0.9.0.rc5)
9
8
  multipart-post (~> 1.1)
10
- ffi (1.1.5-java)
11
- jruby-openssl (0.8.2)
12
- bouncy-castle-java (>= 1.5.0146.1)
13
- jwt (0.1.5)
14
- multi_json (>= 1.0)
15
- kramdown (0.14.1)
16
- launchy (2.1.2)
9
+ json (1.7.7)
10
+ jwt (0.1.8)
11
+ multi_json (>= 1.5)
12
+ kramdown (1.0.2)
13
+ launchy (2.3.0)
17
14
  addressable (~> 2.3)
18
- launchy (2.1.2-java)
19
- addressable (~> 2.3)
20
- ffi (~> 1.1.1)
21
- spoon (~> 0.0.1)
22
- multi_json (1.5.0)
23
- multipart-post (1.1.5)
24
- rake (10.0.3)
15
+ multi_json (1.7.3)
16
+ multipart-post (1.2.0)
17
+ rake (10.0.4)
25
18
  rcov (1.0.0)
26
- rspec (2.12.0)
27
- rspec-core (~> 2.12.0)
28
- rspec-expectations (~> 2.12.0)
29
- rspec-mocks (~> 2.12.0)
30
- rspec-core (2.12.2)
31
- rspec-expectations (2.12.1)
32
- diff-lcs (~> 1.1.3)
33
- rspec-mocks (2.12.1)
34
- spoon (0.0.1)
35
- yard (0.8.3)
19
+ rspec (2.13.0)
20
+ rspec-core (~> 2.13.0)
21
+ rspec-expectations (~> 2.13.0)
22
+ rspec-mocks (~> 2.13.0)
23
+ rspec-core (2.13.1)
24
+ rspec-expectations (2.13.0)
25
+ diff-lcs (>= 1.1.3, < 2.0)
26
+ rspec-mocks (2.13.1)
27
+ yard (0.8.6.1)
36
28
 
37
29
  PLATFORMS
38
- java
39
30
  ruby
40
31
 
41
32
  DEPENDENCIES
42
33
  addressable (>= 2.3.1)
43
34
  extlib (>= 0.9.15)
44
- faraday (~> 0.8.1)
35
+ faraday (>= 0.9.0.rc5)
45
36
  jruby-openssl
37
+ json (~> 1.7.7)
46
38
  jwt (>= 0.1.5)
47
39
  kramdown
48
40
  launchy (>= 2.1.1)
data/README.md CHANGED
@@ -25,28 +25,30 @@ Signet is an OAuth 1.0 / OAuth 2.0 implementation.
25
25
 
26
26
  ## Example Usage for Google
27
27
 
28
- require 'signet/oauth_1/client'
29
- client = Signet::OAuth1::Client.new(
30
- :temporary_credential_uri =>
31
- 'https://www.google.com/accounts/OAuthGetRequestToken',
32
- :authorization_uri =>
33
- 'https://www.google.com/accounts/OAuthAuthorizeToken',
34
- :token_credential_uri =>
35
- 'https://www.google.com/accounts/OAuthGetAccessToken',
36
- :client_credential_key => 'anonymous',
37
- :client_credential_secret => 'anonymous'
38
- )
39
- client.fetch_temporary_credential!(:additional_parameters => {
40
- :scope => 'https://mail.google.com/mail/feed/atom'
41
- })
42
- # Send the user to client.authorization_uri, obtain verifier
43
- client.fetch_token_credential!(:verifier => '12345')
44
- response = client.fetch_protected_resource(
45
- :uri => 'https://mail.google.com/mail/feed/atom'
46
- )
28
+ ``` ruby
29
+ require 'signet/oauth_1/client'
30
+ client = Signet::OAuth1::Client.new(
31
+ :temporary_credential_uri =>
32
+ 'https://www.google.com/accounts/OAuthGetRequestToken',
33
+ :authorization_uri =>
34
+ 'https://www.google.com/accounts/OAuthAuthorizeToken',
35
+ :token_credential_uri =>
36
+ 'https://www.google.com/accounts/OAuthGetAccessToken',
37
+ :client_credential_key => 'anonymous',
38
+ :client_credential_secret => 'anonymous'
39
+ )
40
+ client.fetch_temporary_credential!(:additional_parameters => {
41
+ :scope => 'https://mail.google.com/mail/feed/atom'
42
+ })
43
+ # Send the user to client.authorization_uri, obtain verifier
44
+ client.fetch_token_credential!(:verifier => '12345')
45
+ response = client.fetch_protected_resource(
46
+ :uri => 'https://mail.google.com/mail/feed/atom'
47
+ )
48
+ ```
47
49
 
48
50
  ## Install
49
51
 
50
- `sudo gem install signet`
52
+ `gem install signet`
51
53
 
52
- Be sure `http://rubygems.org/` is in your gem sources.
54
+ Be sure `https://rubygems.org` is in your gem sources.
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- gem 'faraday', '~> 0.8.1'
16
15
  require 'faraday'
17
16
  #require 'faraday/utils'
18
17
 
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- gem 'faraday', '~> 0.8.1'
16
15
  require 'faraday'
17
16
  #require 'faraday/utils'
18
17
 
@@ -22,7 +21,6 @@ require 'signet'
22
21
  require 'signet/errors'
23
22
  require 'signet/oauth_2'
24
23
 
25
- gem 'jwt', '~> 0.1.4'
26
24
  require 'jwt'
27
25
 
28
26
  module Signet
@@ -191,6 +189,8 @@ module Signet
191
189
  # The current ID token for this client.
192
190
  # - <code>:expires_in</code> -
193
191
  # The time in seconds until access token expiration.
192
+ # - <code>:expires_at</code> -
193
+ # The time as an integer number of seconds since the Epoch
194
194
  # - <code>:issued_at</code> -
195
195
  # The timestamp that the token was issued at.
196
196
  #
@@ -209,6 +209,7 @@ module Signet
209
209
 
210
210
  self.access_token = options["access_token"] if options["access_token"]
211
211
  self.expires_in = options["expires_in"] if options["expires_in"]
212
+ self.expires_at = options["expires_at"] if options["expires_at"]
212
213
 
213
214
  # The refresh token may not be returned in a token response.
214
215
  # In which case, the old one should continue to be used.
@@ -720,13 +721,22 @@ module Signet
720
721
  #
721
722
  # @return [Integer] The access token lifetime.
722
723
  def expires_at
723
- if @issued_at && @expires_in
724
+ if @expires_at
725
+ @expires_at
726
+ elsif @issued_at && @expires_in
724
727
  return @issued_at + @expires_in
725
728
  else
726
729
  return nil
727
730
  end
728
731
  end
729
732
 
733
+ ##
734
+ # Limits the lifetime of the access token as number of seconds since
735
+ # the Epoch
736
+ def expires_at=(new_expires_at)
737
+ @expires_at = Time.at new_expires_at
738
+ end
739
+
730
740
  ##
731
741
  # Returns true if the access token has expired.
732
742
  #
@@ -17,8 +17,8 @@ unless defined? Signet::VERSION
17
17
  module Signet
18
18
  module VERSION
19
19
  MAJOR = 0
20
- MINOR = 4
21
- TINY = 5
20
+ MINOR = 5
21
+ TINY = 0
22
22
 
23
23
  STRING = [MAJOR, MINOR, TINY].join('.')
24
24
  end
@@ -20,8 +20,6 @@ require 'spec_helper'
20
20
 
21
21
  require 'signet/oauth_2/client'
22
22
  require 'openssl'
23
-
24
- gem 'jwt', '~> 0.1.4'
25
23
  require 'jwt'
26
24
 
27
25
  conn = Faraday.default_connection
@@ -352,6 +350,23 @@ describe Signet::OAuth2::Client, 'configured for Google userinfo API' do
352
350
  @client.should_not be_expired
353
351
  end
354
352
 
353
+ it 'should allow the expires_at time to be updated' do
354
+ expires_at = Time.now.round - 100
355
+ @client.update_token!(
356
+ :expires_at => expires_at.to_i,
357
+ :expires_in => nil
358
+ )
359
+ @client.expires_at.should == expires_at
360
+ @client.should be_expired
361
+ end
362
+
363
+ it 'should allow setting expires_at manually' do
364
+ expires_at = Time.now.round + 100
365
+ @client.expires_at = expires_at.to_i
366
+ @client.expires_at.should == expires_at
367
+ @client.should_not be_expired
368
+ end
369
+
355
370
  it 'should raise an error if the authorization endpoint is not secure' do
356
371
  @client.client_id = 'client-12345'
357
372
  @client.client_secret = 'secret-12345'
@@ -10,4 +10,7 @@ $:.uniq!
10
10
 
11
11
  require 'rubygems'
12
12
  require 'signet'
13
- require 'rspec'
13
+ require 'rspec'
14
+
15
+ require 'faraday'
16
+ Faraday::Adapter.load_middleware(:test)
@@ -22,7 +22,7 @@ namespace :gem do
22
22
  s.rdoc_options.concat ["--main", "README.md"]
23
23
 
24
24
  s.add_runtime_dependency("addressable", ">= 2.2.3")
25
- s.add_runtime_dependency("faraday", "~> 0.8.1")
25
+ s.add_runtime_dependency("faraday", ">= 0.9.0.rc5")
26
26
  s.add_runtime_dependency("multi_json", ">= 1.0.0")
27
27
  s.add_runtime_dependency("jwt", ">= 0.1.5")
28
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: signet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-18 00:00:00.000000000Z
12
+ date: 2013-05-31 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
16
- requirement: &70325836933680 !ruby/object:Gem::Requirement
16
+ requirement: &70222590324220 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 2.2.3
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70325836933680
24
+ version_requirements: *70222590324220
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: faraday
27
- requirement: &70325836932980 !ruby/object:Gem::Requirement
27
+ requirement: &70222590323640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ~>
30
+ - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.8.1
32
+ version: 0.9.0.rc5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70325836932980
35
+ version_requirements: *70222590323640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: multi_json
38
- requirement: &70325836931580 !ruby/object:Gem::Requirement
38
+ requirement: &70222590323140 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.0.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70325836931580
46
+ version_requirements: *70222590323140
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jwt
49
- requirement: &70325836928460 !ruby/object:Gem::Requirement
49
+ requirement: &70222590322620 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.1.5
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70325836928460
57
+ version_requirements: *70222590322620
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70325836921580 !ruby/object:Gem::Requirement
60
+ requirement: &70222590322100 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70325836921580
68
+ version_requirements: *70222590322100
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70325836921000 !ruby/object:Gem::Requirement
71
+ requirement: &70222590321620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.11.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70325836921000
79
+ version_requirements: *70222590321620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: launchy
82
- requirement: &70325836920220 !ruby/object:Gem::Requirement
82
+ requirement: &70222590321100 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: 2.1.1
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70325836920220
90
+ version_requirements: *70222590321100
91
91
  description: ! 'Signet is an OAuth 1.0 / OAuth 2.0 implementation.
92
92
 
93
93
  '