Skip to content

Issue sending emails with gmailr via cron script #124

@sdisav

Description

@sdisav

I have an R server setup that I use to create and automatically send reports using cron and gmailR package (i.e. non-interactive session). Prior to the most recent version release if I ran:

options(httr_oob_default=TRUE) 
gmail_auth(path = "gmailr.json")

It would return the following prompt:

  • Use a local file ('.httr-oauth'), to cache OAuth access credentials between R sessions?

If you hit yes, it went through the authentication dance and then created the .httr-oauth token that was cached. Once the token was cached, I had several cron scripts that were scheduled to run that would automatically generate and email reports.

With the newest version of gmailR, if I run

gm_auth_configure(key = key, secret = secret, path = path, app = oauth_app(appname, key, secret), cache = TRUE)
gm_auth()

It returns the following prompt:

  • The gmailr package is requesting access to your Google account. Select a pre-authorised account or enter '0' to obtain a new token. Press Esc/Ctrl + C to abort.

I can authenticate by selecting my account or I can go through the authentication dance but it does not cache a .httr-oauth token. If I run a script manually, it auto-refreshes the stale OAuth token and sends. However, anytime I try to send an email through an automated cron script, it returns the following error:

  • Error: Must create an app and register it with gm_auth_configure()

Any insight into what I am doing wrong or how I can fix this would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions