jdeboer/ganalytics

Error: could not find function "new_oauth"

artemklevtsov opened this issue · 7 comments

Hi.

In first thank you for this an interesting realisation GA APi access from R.

But seems now I can't get it worked. I follow instructions from README.

install_github(repo = "ganalytics", username = "jdeboer")
install.packages(c("plyr", "stringr", "RJSONIO", "Rook", "httpuv"))

then restart R-session.

library(ganalytics)
Sys.setenv(GANALYTICS_CONSUMER_ID = "myKey",
GANALYTICS_CONSUMER_SECRET = "mySecret")
ga.query <- GaQuery(profileID)
GetGaData(ga.query)
Error in GetGaData(ga.query) : could not find function "new_oauth"

I also trid pass key and secret to GetGaData with same results.

Does I forgot about something?

oh, I have same problem with ganalytics package :(

This might be caused by installing the latest version of httr from CRAN which the ganalytics package is currently incompatible with. Try reinstalling the branch of httr referred to in the Readme instructions as a workaround for the interim.

# Install devtools via CRAN
install.packages("devtools", dependencies = TRUE)
# Install httr branch via GitHub repository
library(devtools)
install_github(repo = "httr", username = "jdeboer")

It works but it's temporary workground. Do you plan provide compability with a new versions of httr package?

At the first blush according with this example:

in GetGa.R

oauth <- new_oauth(key = NULL, secret = NULL,
                   file = query@authFile,
                   scope = "https://www.googleapis.com/auth/analytics.readonly",
                   base_url = "https://accounts.google.com/o/oauth2",
                   authorize = "auth", access = "token", appname = "GANALYTICS")

should replace something like this

oauth <- oauth2.0_token(endpoint = oauth_endpoints("google"),
                        app = oauth_app(appname = "GANALYTICS",
                                        key = key, secret = secret),
                        use_oob = FALSE,
                        scope = "https://www.googleapis.com/auth/analytics.readonly")

in GetApiRequest.R

data.json <- oauth2.0_GET(url = url, oauth = oauth)

to

data.json <- GET(url = url, config = config(token = oauth))

May be something else.

~~
with best wishes,
Artem

Thanks Artem! You're code is correct and I've incorporated your changes as well as a few other modifications needed. I've tested on my machine and it is working with the latest version of httr now. Please let me know if this is working for you too.

I tested latest changes with a positive results.

Thanks.