Clarification for locating .RDS OAuth tokens generated by `gargle` package - r

Not strictly an RStudio question but the relevant packages are maintained by this community I think.
Apologies for not providing a working example of the problem. The question pertains to use within a container, and I am not sure if an example will provide clarity. :|
I am reading this about non-interactive authentication to google, for googlesheets/googledrive (either will do).
https://cran.r-project.org/web/packages/gargle/vignettes/non-interactive-auth.html
I am confused by the following:
If you know the filepath to the token you want to use, you could use readRDS() to read it and provide as the token argument to the wrapper’s auth function.
How would you know this filepath? That requires some attention to the location of gargle’s OAuth token cache folder, which is described in the next section.
I can't find a clear description in this or the linked documents of where to find the .RDS file.
My use-case is to read or download a googlesheet (via googlesheets or googledrive packages) within a docker package.
I was previously doing this just fine with the old token setup, before google made the changes their side.
Also I have no problem running non-interactively within a scrip on my machine, using httr::oauth_app and drive_auth_configure, then drive_auth as described in the above link.
I am just not clear as to how I can locate the .RDS file from the above documentation.
If you could give a brief description, or if you were so kind as to provide a link to other documents, or sections of the above that I have overlooked or misunderstood I would be very grateful.
Thank you!
Simon

Related

Is there a way to look at previous versions of code in an R Statistics file?

Is there a way to look back at previous code in a file? For instance maybe be able to revert to an earlier saved version or somehow see changes the file code went through?
Short answer: no.
Unless your changes are tracked in some sort of source control (like git) or you keep backups of your files, there is no way to see previous version of a script file. A .R script is just plain text files. They do not store their own history just like other documents or images on your computer don't either. Sorry.
If that's something you want to do in the future, Rstduio makes it easy to integrate with git. Check out this guide to Connect RStudio to Git and GitHub

Temporarily Stop R From Recording History

I find it very useful, in general, for my R history to be saved. I refer to it weekly, or more. Exploratory work in the console gradually gets refined and added to a file.
Occasionally a command will have a secret in it like an API key or searching a dataframe with confidential info, in which case I would like to be able to disable history being saved just for that one command and re-enable it immediately after. Something as much like bash's ignorespace option as possible.
I would be happy for a solution that worked in either R or RStudio, both would be even better. I know history can be manually disabled by going to Tools > Options > General > Always save history but I'm looking for either a command (or keyboard shortcut) so it can be turned on or off quickly.
Edit: something I thought might work but seemed not to help at all was settling "R_HISTFILE" to FALSE or a non-existent file. It doesn't to help the RStudio history at least. My examination of what it actually did has not been very thorough yet.
As i stated in the comment, there are ways to avoid having an API key stored in the history file. As the comment seemed to have collected some upvotes it might be worth the effort to expand it in an answer.
Occasionally a command will have a secret in it like an API key or searching a dataframe with confidential info, in which case I would like to be able to disable history being saved just for that one command and re-enable it immediately after.
I think right now, it is only possible to find a sultion for the "API key issue" with the current version of RStudio, see the comments in the links of paragraph: "Concerning the confidential info:"
However, while waiting for a soultion this page could be of interest for you: https://cran.r-project.org/web/packages/httr/vignettes/secrets.html.
Avoid having the API key stored is easier than the confidential info of a data.frame i think.
Concerning the confidential info:
Longer to introduce, but "clean":
I think its worth to add it as a feature request for the great rstudioapi package or adding up here:
https://support.rstudio.com/hc/en-us/community/posts/115000932128-RStudio-Config-Files
Related: https://github.com/rstudio/rstudio/issues/1607 (would enable user to write their own addin)
Related: https://community.rstudio.com/t/configure-rstudio-global-options-on-install/14881 (would enable user to write their own addin)
Fast to introduce, but dirty:
- a hacky dirty workaround would be to introduce an add-in to delete the last insert in the history file.
Information storage
Here is described where the settings are stored: https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State.
You can navigate to the Rstudio-desktop folder. E.g. on windows enter: %localappdata%\RStudio-Desktop in the explorer.
The global options you are looking for can be found here: ..\monitored\user-settings\user-settings.
The flag "always save history,..." in Rstudio - Tools - Global Options - General is the first value in ..\monitored\user-settings\user-settings.
Unfortunately, RStudio won´t listen on changes in that file, so you would have to restart RStudio to make changes be visible. So for now it is not an option for temporarily stopping Rstudio from recording the history.
Concerning the API key, let me summarize a few approaches of that page:
Add a "popup" to ask for the secret: rstudioapi::askForPassword()
use environmental variables. You avoid the popup, but i think it just moves the logging of the confidential info from the "history" to the envar.
finally see the keyring package for storing the data in the secret store of your OS.

get belonging notebook to note from an .enex-file

I have notes exported to enex. I want to process them with php-cli (the language I am most mature). There is no way to get the name of the notebook, a note is belonging to, is it? Are there plans to include this information into the .enex-files?
Thanks in advance!
Nope, you won't be able to get the notebook from the enex file.
There's nothing in the DTD and as stated in this blog post :
ENEX files do not represent how notes are stored within the Evernote service or applications; they are a portable export format that allows notes to be migrated in their entirety between systems and accounts.
And I'm pretty confident that this won't change anytime soon, sorry.

Setting up rfigshare with API keys

I have recently installed the rfigshare package. In order to use it, I need to get figshare API keys to to use it properly. The documentation I found so far is obsolete (see here). Does anyone knows the procedure to follow?
From the package README:
The first time you use an rfigshare function, it will ask you to authenticate online. Just log in and click okay to authenticate rfigshare. R will allow you to cache your login credentials so that you won't be asked to authenticate again (even between R sessions), as long as you are using the same working directory in future.
So, just load the package using library("rfigshare") and call any function. You will be automatically prompted to login and store an OAuth credential locally, which will then be automatically used in subsequent function calls.

How to get the directory information in the workspace of Light Table?

Opening recent workspace shows the directories and files that I opened before, then how to get the directory location of them? I tried right click, but I see no information.
I expect something like this from Code Runner.
[I'm a member of the open source Light Table team.]
Light Table doesn't provide that info as you expect.
I agree that that would be a really useful feature, especially when you have multiple directories with the same name in different paths.
Maybe a tooltip when you hover over a directory that shows the full path would be the minimal change that would be helpful.
If you're willing to contribute, or know someone that is, feel free to create new issues in the GitHub repo for each of the Code Runner features you'd like to be implemented. Otherwise, add them to the feature wishlist wiki page.
These features could be implemented as plugins but I think some of them might arguably be fine implemented in the core app code. Pull requests welcome!

Resources