[ESS] TWITTER API environment variables

Dirk Eddelbuettel edd @end|ng |rom deb|@n@org
Thu Apr 9 16:59:17 CEST 2020


On 9 April 2020 at 10:32, Ista Zahn via ESS-help wrote:
| Are you sure you've diagnosed the issue correctly? From what I can see
| the name of the environment variable is always TWITTER_PAT, at least
| in the current rtweet release (0.7.0). get_tokens calls twitter_pat
| (https://github.com/ropensci/rtweet/blob/v0.7.0/R/tokens.R#L120) and
| twitter_pat hard-codes TWITTER_PAT
| (https://github.com/ropensci/rtweet/blob/v0.7.0/R/tokens.R#L371). In
| short I don't see anything suggesting that the name of the environment
| variable includes a user name at all.

Seconded. AFAICT ESS does nothing all that special to R (apart from its
little integration bits, but that is orthogonal).

What I have done for years is a part of ~/.Rprofile being conditioned by
  if (interactive()) ...
which R-called-from-ESS runs as it should---and I see it as it also calls
fortunes::fortune() is part of it. More recently within that section I added

    if (dir.exists("~/.R/profile.d")) {
        files <- list.files("~/.R/profile.d", pattern=".*\\.R$", full.names=TRUE)
        for (f in files) {
            source(f)
        }
    }

and that is a simple way to set _context-specific_ options and env.vars one
may need for various web services. That allows me to git-commit the .Rprofile
without risking to commit tokens and env vars anywhere public (as profile.d/
gets added to .gitignore).

Lastly, for batch / automated twitter (as done e.g. by my CRANberriesFeed and
CRAN Policy Watch cron jobs) I rely on a very small and simple _external_
command called bti. Served me well during the years when rtweet and its
predecessor "matured".

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org



More information about the ESS-help mailing list