Giter VIP home page Giter VIP logo

Comments (8)

EricGoldsmith avatar EricGoldsmith commented on July 17, 2024

Are you storing an instance on disk, per:

https://github.com/skardhamar/rga#advanced-use

from rga.

odonnelladam avatar odonnelladam commented on July 17, 2024

Yes. Or at least attempting to. I'm taking over code from a previous developer so perhaps it's not correct.

Here's what I have now. Should I be doing an open 3 times, or perhaps combine into one command? Do I need to fill in a specific file path after the "where" below, or does this default to the WD?

library(rga)
rga.open(instance="ga")
rga.open(instance="ga", where="~/ga.rga")
rga.open(instance = "ga",
client.id = "myclientid",
client.secret = "myclientsecret")

from rga.

EricGoldsmith avatar EricGoldsmith commented on July 17, 2024

No, 3 calls are not needed. This is what I do:

rga.open(instance = "ga", where="~/ga.rga",
         client.id = getOption("ga.clientId"), client.secret = getOption("ga.clientSecret"))

The getOption() is retrieving credentials from ~/.Rprofile, in order to keep them out of the code.

Do I need to fill in a specific file path after the "where" below, or does this default to the WD?

The ~/ location refers to the home directory ($HOME) of the user running the script. So, not the current working directory (WD). Though, you could store it there if you wanted to.

from rga.

odonnelladam avatar odonnelladam commented on July 17, 2024

OK, makes sense. I've kept it as Home (~/ga.rga), but I'm getting the following error: "Error in if (.self$tokenExpiresIn() <= 0) { : argument is of length zero"

I'm just running the following:

library(rga)
rga.open(instance = "ga", where="~/ga.rga",
client.id = getOption("ga.clientId"), client.secret = getOption("ga.clientSecret"))

I've also tried running the following first, in case I needed to store the ID/CS first:

ga.clientId <- "[myclientidhere]"
ga.clientSecret <- "[mygasecrethere]"

I get the same error each time.

I've also tried running just rga.open(instance="ga") and pasting in the code just in case I needed to have a successful instance opened at least once. When I do that the code you suggested works fine. But if I close R Studio and re-open, thereby ending the instance, I can't just run the code you suggested without getting that same "length zero" error.

What am I missing?

I really appreciate your help with this. I assuming I'm just missing something basic.

from rga.

EricGoldsmith avatar EricGoldsmith commented on July 17, 2024

When using the options mechanism in R, you need to assign them as follow (this is an excerpt from my ~/.Rprofile):

# Google Analytics credentials
options(ga.clientId = "[myclientidhere]")
options(ga.clientSecret = "[mygasecrethere]")

And, remember that every time you modify .Rprofile you need to restart R for it to pick up the changes.

from rga.

odonnelladam avatar odonnelladam commented on July 17, 2024

Damn, I had already done that. Still getting that error. Not sure it's related to the GetOPtion, though. Because I still get the error even if I just declare it in the code such as

rga.open(instance = "ga", where="~/ga.rga",
client.id = "[myclientidhere]",
client.secret = "[mygasecrethere]")

I definitely intend to use the GetOption, though. Just doesn't seem to impact the error.

from rga.

EricGoldsmith avatar EricGoldsmith commented on July 17, 2024

Maybe the ~/ga.rga instance file is corrupt? Maybe try deleting it, then re-running the rga.open() call.

There's a status function that might provide some insight: ga$status(). The output for me looks like:

> ga$status()
Client ID: [myclientidhere]
Client Secret: [mygasecrethere]
Where: ~/ga.rga
Is token valid: TRUE
Token expires in: 3584.93204188347 seconds

from rga.

odonnelladam avatar odonnelladam commented on July 17, 2024

Good call. That's exactly what I did and it seems to be working. I noticed that the timestamp for the ga.rga file wasn't updating even when I authenticated. So I deleted the file, closed down everything and started over. This time when I ran the code it asked me to authenticate and created a new ga.rga file.

I was just testing it before I posted an update.

Thanks for your help with this!

from rga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.