Добавьте адрес пересылки с учетной записью сервиса из Gmail ruby ​​API - PullRequest
0 голосов
/ 26 апреля 2018

Я пытаюсь настроить адрес пересылки для учетной записи с помощью Gmail API.

Я авторизовал API для моей учетной записи Gapps, но я получаю следующую ошибку:

{
 "error": "unauthorized_client",
 "error_description": "Client is unauthorized to retrieve access tokens using this method."
}

Вот пример моего кода:

scope = [Gmail::AUTH_GMAIL_SETTINGS_BASIC]
      attrs = {
         json_key_io: File.open('lib/google/client_secret.json', 'r'),
         scope: scope
       }
       auth = ::Google::Auth::ServiceAccountCredentials.make_creds(attrs)
       impersonate_auth = auth.dup
       impersonate_auth.sub ='paul@myd.com'
       service = ::Google::Apis::GmailV1::GmailService.new
       service.authorization = impersonate_auth
       service.create_user_setting_forwarding_address(ue.email, auto_forwarding_request)

Вот разрешение на эту услугу на моих Gapps:

calendar 
email 
Email (Read/Write/Send)  https://mail.google.com/ 
https://www.google.com/m8/feeds 
https://www.googleapis.com/auth/gmail.settings.basic 
https://www.googleapis.com/auth/gmail.settings.sharing 
profile 
...