lionel_richie 0.2.4 → 0.3.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: 45c95903e74283e8e40a956410abc877b4fdce2c
4
- data.tar.gz: d74aa9ec02e9a078d66b04f0f46aca3560fbf759
3
+ metadata.gz: f27fcc463388c7304b7ad1962c6e1a9410395eb8
4
+ data.tar.gz: 8bc504b7f0f628f7c9929b81e5e10b2f44cf67c7
5
5
  SHA512:
6
- metadata.gz: 683221356b95e9255ca999fd6454a3228fa69694534f9bc7aa9de5fe1e2c72d305f83994304421e97b2ab11a369af2f081df61ec38faab1a00285e0544783050
7
- data.tar.gz: 25cd6db202a126e59ef1cd20f7f028afeb8621007eb980ed3141545ca120a4d20251ccc4cda40e39fd799933f72eb0ae10c79fe217abbcf05e769c735ab3de5a
6
+ metadata.gz: b82b9e20b78ee845efcf62b2e95ebdbe779c1ff410f8cd74bc4e5275cdc06d1b6bc624b47a8890dbb8b6c5afe48ba87ec43c42fad6e565132f17730b93cf3462
7
+ data.tar.gz: 484b84c4d2f7756afa9ca66819a7b62fea7365d49f4ca87ea0a401fa441c61d5c8c507d910be137ae1fb786019af4746e69d8593a87831f29785f894d3febe4d
data/lib/lionel.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'yajl'
2
2
  require 'trello'
3
- require 'google_drive_v0'
3
+ require 'google_drive'
4
4
  require 'launchy'
5
5
  require 'thor'
6
6
  require 'logger'
data/lib/lionel/cli.rb CHANGED
@@ -66,7 +66,7 @@ module Lionel
66
66
 
67
67
  begin
68
68
  export.authenticate
69
- rescue GoogleDriveV0::Error, GoogleDriveV0::AuthenticationError
69
+ rescue GoogleDrive::Error, GoogleDrive::AuthenticationError
70
70
  @google_attempts ||= 0
71
71
  @google_attempts += 1
72
72
  Lionel::GoogleAuthentication.new.refresh
data/lib/lionel/export.rb CHANGED
@@ -131,7 +131,7 @@ module Lionel
131
131
  end
132
132
 
133
133
  def google_session
134
- @google_session ||= GoogleDriveV0.login_with_oauth(configuration.google_token)
134
+ @google_session ||= GoogleDrive.login_with_oauth(configuration.google_token)
135
135
  end
136
136
 
137
137
  def trello_session
@@ -1,56 +1,75 @@
1
+ require "google/api_client"
2
+
1
3
  module Lionel
2
4
  class GoogleAuthentication
3
5
  include Configurable
4
6
 
5
- attr_accessor :access_token
7
+ attr_accessor :access_token, :refresh_token
6
8
  attr_writer :client
7
9
  config_accessor :google_client_id, :google_client_secret
8
10
 
9
11
  def data
10
12
  raise "No access token" unless access_token
11
13
  {
12
- google_token: access_token.token,
13
- google_refresh_token: access_token.refresh_token,
14
+ google_token: access_token,
15
+ google_refresh_token: refresh_token,
14
16
  google_client_id: google_client_id,
15
17
  google_client_secret: google_client_secret
16
18
  }
17
19
  end
18
20
 
19
21
  def retrieve_access_token(authorization_code)
20
- @access_token = client.auth_code.get_token(authorization_code,
21
- :redirect_uri => "urn:ietf:wg:oauth:2.0:oob")
22
+ authorization.code = authorization_code
23
+ authorization.fetch_access_token!
24
+ @access_token = authorization.access_token
25
+ @refresh_token = authorization.refresh_token
22
26
  end
23
27
 
24
28
  def refresh
25
- return false unless refresh_token
29
+ return false unless refresh_token && access_token
30
+
31
+ authorization.access_token = access_token
32
+ authorization.refresh_token = refresh_token
33
+ authorization.refresh!
26
34
 
27
- current_token = OAuth2::AccessToken.from_hash(client,
28
- :refresh_token => refresh_token,
29
- :expires_in => one_year
30
- )
31
- @access_token = current_token.refresh! # returns new access_token
35
+ @access_token = authorization.access_token
32
36
  end
33
37
 
34
38
  def authorize_url
35
- client.auth_code.authorize_url(
36
- :redirect_uri => "urn:ietf:wg:oauth:2.0:oob",
37
- :scope => scopes.join(' ')
38
- )
39
+ authorization.authorization_uri
39
40
  end
40
41
 
41
42
  def api_console_url
42
43
  "https://code.google.com/apis/console"
43
44
  end
44
45
 
46
+ def authorization
47
+ @authorization ||= begin
48
+ auth = client.authorization
49
+ auth.client_id = google_client_id
50
+ auth.client_secret = google_client_secret
51
+ auth.scope = scopes
52
+ auth.expires_in = one_year
53
+ auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
54
+ auth
55
+ end
56
+ end
57
+
45
58
  def client
46
- @client ||= OAuth2::Client.new(google_client_id, google_client_secret,
47
- :site => "https://accounts.google.com",
48
- :token_url => "/o/oauth2/token",
49
- :authorize_url => "/o/oauth2/auth")
59
+ @client ||= Google::APIClient.new(auto_refresh_token: true)
50
60
  end
51
61
 
52
62
  private
53
63
 
64
+ def build_client
65
+ auth = client.authorization
66
+ auth.client_id = google_client_id
67
+ auth.client_secret = google_client_secret
68
+ auth.scope = scopes
69
+ auth.redirect_uri = "urn:ietf:wg:oauth:2.0:oob"
70
+ client
71
+ end
72
+
54
73
  def refresh_token
55
74
  @refresh_token || configuration.google_refresh_token
56
75
  end
@@ -64,7 +83,7 @@ module Lionel
64
83
  end
65
84
 
66
85
  def one_year # in seconds
67
- 31557600
86
+ 60*60*24*36
68
87
  end
69
88
 
70
89
  end
@@ -1,3 +1,3 @@
1
1
  module Lionel
2
- VERSION = "0.2.4"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lionel_richie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Kaffenberger