Gmail api를 ServiceAccount (G Suite 관리)에서 수행하는 것은 어렵습니다.
                                            
                                                
                                                
                                                
                                                
                                                
                                                 5683 단어  google-api-clientgoogle루비
                    
목적
필요한 것
Api scopes
http://www.google.com/m8/feeds/contacts/,http://www.google.com/m8/feeds/groups/,https://mail.google.com/
(어쩐지 모르지만 mail.google.com 범위 만 있으면 권한 오류가 발생하므로이 세 가지 범위가 필수입니다.
샘플 코드 (루비
# frozen_string_literal: true
class GmailDeliveryMethod
  attr_reader :settings
  def initialize(settings)
    @settings = settings
  end
  def deliver(mail)
    credentials = Google::Auth::ServiceAccountCredentials.new(
      token_credential_uri: settings[:token_uri],
      audience: settings[:token_uri],
      scope: Google::Apis::GmailV1::AUTH_SCOPE,
      issuer: settings[:client_email],
      signing_key: OpenSSL::PKey::RSA.new(settings[:private_key]),
      project_id: settings[:project_id],
    )
    credentials.sub = mail.from.first
    gmail = Google::Apis::GmailV1::GmailService.new
    gmail.authorization = credentials
    gmail.send_user_message(
      mail.from.first,
      upload_source: StringIO.new(mail.to_s),
      content_type: 'message/rfc822',
    )
  end
  alias deliver! deliver
end
message = Mail.new(
  from: '[email protected]',
  to: '[email protected]',
  subject: 'TEST MAIL',
  body: "TEST MAIL #{Time.current}",
)
GmailDeliveryMethod.new({...}).deliver(message)

 
                Reference
이 문제에 관하여(Gmail api를 ServiceAccount (G Suite 관리)에서 수행하는 것은 어렵습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/aileron/items/4b7ea742797aa01e7dcd텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)