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: 27a0ef9770c2172e574541dbb950bc4f7b074163a42903acfeadf2570c95609c
4
- data.tar.gz: 499e917ef4edf4e6f4f3a3f8f51f5305f60c1d67bd6706ce94f8644ef331a2ff
3
+ metadata.gz: 5f1211f5de7810d50677db70818fd068f7566038fcc457baaef79c072b7baad8
4
+ data.tar.gz: 45ce5f184da4bd4c37b9b4daaa9fa99f665521ea180ad569479dce1951efade1
5
5
  SHA512:
6
- metadata.gz: b0dcd0f7f2c8fbd565b680866e7a29e72e9c8acb3891be7a36e521913dd53ff392a9490d5c3ef94354324f127efe0e78c881ddc9294ecd65cadf56529c7c0ba0
7
- data.tar.gz: 9a4f954d7350be1d603de16aa1cd813c2046d1516ffe99cb7b4ee13b5e4bece972a0fcd9b778777f166e39a44fc71a5049f755bd1acaecf1a201b6db66518d14
6
+ metadata.gz: 33e5af056400a8b5f7a593ce3a3443765b98f27f88c5b43e144500e3f2860887f892b3ea215e9d74b3b0675745f1531369aa0eee830696e095eeaec2f15ceaac
7
+ data.tar.gz: da4fdbb67654d225af19909c38811b40b37cc4b9846f3b6585af477ddf5e5c50844c4b1745026bdd474091e258cf5e19e291694e64810015fae399454b9e44f6
data/README.markdown CHANGED
@@ -1,8 +1,12 @@
1
- # mail_xoauth2
1
+ # mail_xoauth2 [![Gem Version](https://badge.fury.io/rb/mail_xoauth2.svg)](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
@@ -5,7 +5,7 @@ require 'net/imap'
5
5
  module MailXoauth2
6
6
  class ImapXoauth2Authenticator
7
7
  def process(_data)
8
- build_oauth2_string(@user, @oauth2_token, true)
8
+ build_oauth2_string(@user, @oauth2_token)
9
9
  end
10
10
 
11
11
  private
@@ -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, encode_base64 = false)
11
- oauth2_string = format("user=%<user>s\1auth=Bearer %<token>s\1\1".encode('us-ascii'), user: user, token: oauth2_token)
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, true)
24
- res = send_xoauth2(auth_string)
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?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module MailXoauth2
2
- VERSION = '1.0'.freeze
4
+ VERSION = '1.0.1'
3
5
  end
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: '1.0'
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-07 00:00:00.000000000 Z
11
+ date: 2018-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mocha