smtp-xoauth 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +54 -0
  2. data/lib/smtp-oauth.rb +14 -0
  3. metadata +76 -0
data/README ADDED
@@ -0,0 +1,54 @@
1
+ *** SMTP XOAUTH for ruby's Net::SMTP ***
2
+
3
+ Based on http://code.google.com/apis/gmail/oauth/protocol.html
4
+
5
+
6
+ Requires a signed input base string passed in for password secret - the oauth gem is helpful in creating this
7
+
8
+ Leaves the username as a parameter to maintain compatibility with other auth_ methods
9
+
10
+ #todo - add functions to more easily create this string given the user's email address, token and secret
11
+ #todo - figure out how to make gems and such properly
12
+
13
+
14
+ ** USAGE EXAMPLE **
15
+
16
+ Basically all this library provides is the new :auth => :oauth argument to Net::SMTP (see example below)
17
+
18
+ To get something working out with minimal work, use Google's Python commandline script to generate a valid auth_string
19
+ http://code.google.com/p/google-mail-xoauth-tools/wiki/XoauthDotPyRunThrough and use the Pony mail code below
20
+ to send a message (gem install pony)
21
+
22
+
23
+ The auth_string below is what an "initial client request" looks like before Base64 encoding -
24
+ this is what's passed to the auth_xoauth function as a string.
25
+
26
+ <pre>
27
+
28
+ require 'smtp-xoauth'
29
+ require 'pony'
30
+
31
+ # to see this working get yourself a valid auth_string using google's xoauth.py utility
32
+ auth_string = 'GET https://mail.google.com/mail/b/youremail@gmail.com/smtp/ oauth_consumer_key="oftenyourdomain.com",oauth_nonce="6762341348542013497",oauth_signature="CqU4ov0ashDqMrWXw6yKWTbbjE%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1270697273",oauth_token="1%2F3cJbEP_tmYo0svadifjadsfWpQgBP6-NVeeBHDUXOek",oauth_version="1.0"'
33
+
34
+
35
+ Pony.mail( :from => "youremail@gmail.com",
36
+ :to => "destination@anywhere.com",
37
+ :body => "no big deal",
38
+ :subject => "oauth'ed message",
39
+ :content_type => 'text/plain',
40
+ :via => :smtp,
41
+ :smtp => {
42
+ :host => 'smtp.gmail.com',
43
+ :port => '587',
44
+ :tls => true,
45
+ :user => 'gmailusername',
46
+ :password => auth_string,
47
+ :auth => :oauth
48
+ })
49
+
50
+
51
+ </pre>
52
+
53
+ To rebuild the gem after mucking with the code, just do "rake gem"
54
+ Contact alvin via github if you have any suggestions or contributions.
@@ -0,0 +1,14 @@
1
+ module Net
2
+ class SMTP
3
+ def auth_oauth( user, secret )
4
+ res = critical {
5
+ # xoauth secret needs to be base64 encoded WITHOUT newlines
6
+ # the secret looks like this prior to encoding:
7
+ # GET https://mail.google.com/mail/b/therealemail@gmail.com/smtp/ oauth_consumer_key="oftenyourdomain.com",oauth_nonce="6762341348542013497",oauth_signature="CqU4ov0ashDqMrWXw6yKWTbbjE%3D",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1270697273",oauth_token="1%2F3cJbEP_tmYo0svadifjadsfWpQgBP6-NVeeBHDUXOek",oauth_version="1.0"
8
+ get_response("AUTH XOAUTH #{base64_encode(secret).gsub(/\n/,'')}")
9
+ }
10
+ raise SMTPAuthenticationError, res unless /\A2../ === res
11
+
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: smtp-xoauth
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 15
9
+ version: 0.0.15
10
+ platform: ruby
11
+ authors:
12
+ - Alvin Engler
13
+ autorequire: name
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-13 00:00:00 -07:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: oauth
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 3
30
+ - 6
31
+ version: 0.3.6
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ description:
35
+ email: alvin@alvinengler.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files:
41
+ - README
42
+ files:
43
+ - lib/smtp-oauth.rb
44
+ - README
45
+ has_rdoc: true
46
+ homepage: http://alvinengler.com/smtp-oauth
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options: []
51
+
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.6
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Adds auth_xoauth to Ruby's core Net::SMTP to support Google's new XOAUTH http://code.google.com/apis/gmail/oauth/protocol.html
75
+ test_files: []
76
+