artemklevtsov / RGA

A Google Analytics API client for R
http://cran.r-project.org/package=RGA
32 stars 13 forks source link

Error: token : cannot add bindings to a locked environment #18

Closed diegocgaona closed 8 years ago

diegocgaona commented 8 years ago

Hi,

I'm having the following error when I to authorize the token:

authorize(token = ga_token)
Error in tokens[[token$hash()]] <- token : cannot add bindings to a locked environment

If i use the interactive console, I try again and again and then, works. But I can't do with knitr...

I'm using R version 3.2.3 and RStudio Version 0.99.489.

Thanks!

artemklevtsov commented 8 years ago

But it works for me:

---
output:
  md_document:
    variant: markdown_github
---

```{r}
ga_token <- readRDS(".ga-token.rds")[[1]]
library(RGA)
authorize(token = ga_token)
list_profiles()[[1]]
list_profiles(token = ga_token)[[1]]


I tried render this file into RStuiod and with Rscript.

Please provide more info about the `ga_token` object and versions of the packages.
diegocgaona commented 8 years ago

Sorry, I had did some stupid thing... I used: (in the real code I used my access keys)

ga_token <- authorize()

The, the ga_token was saved as a environment. Now I did like you, and I read the RDS saved:

ga_token <- readRDS(".ga_token.rds")[[1]]

Now, worked fine. Thanks!!!

artemklevtsov commented 8 years ago
> library(RGA)
> token <- authorize()
Access token will be stored in the '.ga-token.rds' file.
> authorize(token = token)

also works. Best practice is call authorize() with your own cleint.id, client.secret and cache.