Skip to content

Instantly share code, notes, and snippets.

@BradleyJohnson
Created October 22, 2015 00:03
Show Gist options
  • Save BradleyJohnson/896d386d0959e8362a13 to your computer and use it in GitHub Desktop.
Save BradleyJohnson/896d386d0959e8362a13 to your computer and use it in GitHub Desktop.
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
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