0

My API call to github in the R-Studio console works just fine (httr package) but breaks whenever I attempt to knit a pdf. In the console I have to manually go to 'localhost:1410' when first authorizing my credentials but apparently this is unable to happen while knitting.

```{r}
oauth_endpoints("github")
myapp <- oauth_app("github", "xxxxxxxxxx")
github_token <- oauth2.0_token(oauth_endpoints("github"), myapp)
gtoken <- config(token = github_token)
req <- with_config(gtoken, GET("https://api.github.com/repos/mbostock/d3/stats/participation"))
stop_for_status(req)
result = content(req)
```

The error produced is

Error: oauth_listener() needs an interactive environment. Execution halted.

Any suggestions or workarounds?

Ted Petrou
  • 59,042
  • 19
  • 131
  • 136
  • 2
    Is there a reason you're not caching your credentials with the local cache? – hadley Jul 19 '14 at 19:22
  • Heh, the reason is that I had no idea what a 'local cache' was. I used `library(SOAR)` with `Store` function and everything is working. Maybe if I paid attention at Rice I would have known. Say hi to Dr. Ensor. Thanks! – Ted Petrou Jul 20 '14 at 12:41
  • @TedPetrou Create the token in an interactive session and set `cache=TRUE`. Then you can load the cached token in your knitr doc. – Thomas Jul 22 '14 at 10:01

0 Answers0