Created
October 22, 2015 00:03
-
-
Save BradleyJohnson/896d386d0959e8362a13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'google/apis/gmail_v1' | |
require 'uri' | |
require 'mail' | |
Gmail = Google::Apis::GmailV1 | |
class MailService | |
def initialize(params) | |
@params = params | |
end | |
def call | |
message = Gmail::Message.new | |
service = Gmail::GmailService.new | |
message.raw = "VG86IGJkam9obnNvOEBnbWFpbC5jb20KRnJvbTogYnJhZGxleS5kYXZpZC5qb2huc29uQGdtYWlsLmNvbQpTdWJqZWN0OiBUZXN0IHN1YmplY3QKClRlc3QgYm9keQ" | |
service.request_options.authorization = current_user.token.fresh_token | |
result = service.send_user_message(current_user.email, message) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.config.middleware.use OmniAuth::Builder do | |
provider :google_oauth2, ENV["GOOGLE_CLIENT_ID"], ENV["GOOGLE_CLIENT_SECRET"], | |
{ | |
scope: ['email', 'https://www.googleapis.com/auth/gmail.modify'], | |
hd: ENV["GOOGLE_DOMAIN"], | |
access_type: 'offline' | |
} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment