navi_email_sync 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gmail_client.rb +21 -11
- data/lib/navi_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b1adf63fea9de38a1b9d436bf203145a525649937e2fd40f5a02a91e6b9447e
|
4
|
+
data.tar.gz: b23865f07b4813281998e695e13ff00f9bd737ff516cbcd4f4bbb6f3f0b3702d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03d65abca7c01fae9757740e392402e05625b85afc710fce25b27a29563f9adfc59a069ffce6caa0bb700627acf210014b9914873bc5704fb0c92bb00c4d3374
|
7
|
+
data.tar.gz: 01c925f82dde2da7b0f21133e441754195c4021a82988fcaf060c976c2c191bade12133d1143722e7cb408d16ccab0a394b72b7014b20ec40f56e456decbc2f8
|
data/lib/gmail_client.rb
CHANGED
@@ -29,6 +29,8 @@ module GmailClient
|
|
29
29
|
|
30
30
|
attr_accessor :total_emails
|
31
31
|
|
32
|
+
attr_accessor :auth_client
|
33
|
+
|
32
34
|
@logglyTag
|
33
35
|
|
34
36
|
def logger
|
@@ -69,20 +71,23 @@ module GmailClient
|
|
69
71
|
@service.authorization = cred
|
70
72
|
end
|
71
73
|
|
72
|
-
def init_apis_cloud client_path, scope, token,
|
74
|
+
def init_apis_cloud client_path, scope, token, type = "code"
|
73
75
|
client_secrets = Google::APIClient::ClientSecrets.load client_path
|
74
|
-
auth_client = client_secrets.to_authorization
|
75
|
-
auth_client.
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
76
|
+
@auth_client = client_secrets.to_authorization
|
77
|
+
@auth_client.update!(:scope => scope,
|
78
|
+
:redirect_uri => "postmessage")
|
79
|
+
if(type == "code")
|
80
|
+
@auth_client.code = token
|
81
|
+
else
|
82
|
+
@auth_client.grant_type = "refresh_token"
|
83
|
+
@auth_client.refresh_token = token
|
84
|
+
end
|
82
85
|
|
86
|
+
@auth_client.refresh!
|
87
|
+
# @auth_client.client_secret = nil
|
83
88
|
@service = Google::Apis::GmailV1::GmailService.new
|
84
89
|
@service.client_options.application_name = APPLICATION_NAME
|
85
|
-
@service.authorization = Signet::OAuth2::Client.new(
|
90
|
+
@service.authorization = Signet::OAuth2::Client.new(JSON.parse(@auth_client.to_json))
|
86
91
|
end
|
87
92
|
|
88
93
|
def authorization_url
|
@@ -101,8 +106,13 @@ module GmailClient
|
|
101
106
|
begin
|
102
107
|
# fetch all the email contents
|
103
108
|
# data = imap.uid_fetch(message_id, "RFC822")
|
104
|
-
|
109
|
+
if @auth_client.expired?
|
110
|
+
@auth_client.grant_type = "refresh_token"
|
111
|
+
@auth_client.refresh!
|
112
|
+
@service.authorization = Signet::OAuth2::Client.new(JSON.parse(@auth_client.to_json))
|
113
|
+
end
|
105
114
|
|
115
|
+
result = @service.get_user_message('me', message_id)
|
106
116
|
|
107
117
|
process_email_block.call result, i, i == @message_ids.length-1, message_id
|
108
118
|
|
data/lib/navi_client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navi_email_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sanjib
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|