mail_xoauth2 1.0 → 1.0.1
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f1211f5de7810d50677db70818fd068f7566038fcc457baaef79c072b7baad8
|
4
|
+
data.tar.gz: 45ce5f184da4bd4c37b9b4daaa9fa99f665521ea180ad569479dce1951efade1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e5af056400a8b5f7a593ce3a3443765b98f27f88c5b43e144500e3f2860887f892b3ea215e9d74b3b0675745f1531369aa0eee830696e095eeaec2f15ceaac
|
7
|
+
data.tar.gz: da4fdbb67654d225af19909c38811b40b37cc4b9846f3b6585af477ddf5e5c50844c4b1745026bdd474091e258cf5e19e291694e64810015fae399454b9e44f6
|
data/README.markdown
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
# mail_xoauth2
|
1
|
+
# mail_xoauth2 [](https://badge.fury.io/rb/mail_xoauth2)
|
2
2
|
Get access to IMAP and STMP via OAuth2, using the standard Ruby Net libraries.
|
3
3
|
|
4
4
|
This gem is based on and inspired by [gmail_xoauth](https://github.com/nfo/gmail_xoauth).
|
5
5
|
|
6
|
+
## Install
|
7
|
+
|
8
|
+
$ gem install mail_xoauth2
|
9
|
+
|
6
10
|
## Usage
|
7
11
|
|
8
12
|
### IMAP OAuth 2.0
|
@@ -7,11 +7,8 @@ module MailXoauth2
|
|
7
7
|
#
|
8
8
|
# +user+ is an email address: roger@gmail.com
|
9
9
|
# +oauth2_token+ is the oauth2 token
|
10
|
-
def build_oauth2_string(user, oauth2_token
|
11
|
-
|
12
|
-
oauth2_string = Base64.strict_encode64(oauth2_string) if encode_base64
|
13
|
-
|
14
|
-
oauth2_string
|
10
|
+
def build_oauth2_string(user, oauth2_token)
|
11
|
+
format("user=%<user>s\1auth=Bearer %<token>s\1\1".encode('us-ascii'), user: user, token: oauth2_token)
|
15
12
|
end
|
16
13
|
end
|
17
14
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'net/smtp'
|
2
4
|
require 'base64'
|
3
5
|
|
@@ -20,8 +22,9 @@ module MailXoauth2
|
|
20
22
|
def auth_xoauth2(user, oauth2_token)
|
21
23
|
check_auth_args user, oauth2_token
|
22
24
|
|
23
|
-
auth_string = build_oauth2_string(user, oauth2_token
|
24
|
-
|
25
|
+
auth_string = build_oauth2_string(user, oauth2_token)
|
26
|
+
b64_auth_string = Base64.strict_encode64(auth_string)
|
27
|
+
res = send_xoauth2(b64_auth_string)
|
25
28
|
|
26
29
|
# See note about SMTP protocol exchange in https://developers.google.com/gmail/xoauth2_protocol
|
27
30
|
res = get_final_status if res.continue?
|
data/lib/mail_xoauth2/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_xoauth2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fabian Jäger
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|