get_credentials {lares} | R Documentation |
Load Credentials from a YML File
Description
Load credentials from a local YML file. You can set your .Renviron
and the LARES_CREDS
parameter to remember (forever) the directory
of your credentials' file. To use it later, you may leave dir = NA
.
You may also use this function for external (non-lares
) code/use.
Usage
get_credentials(
from = NA,
dir = NA,
filename = "config.yml",
env = "LARES_CREDS",
...
)
get_creds(
from = NA,
dir = NA,
filename = "config.yml",
env = "LARES_CREDS",
...
)
Arguments
from |
Character. Family of values to import from the YML file.
If you don't know these names, set |
dir |
Character. Credentials directory where your YML file is.
If used frequently, set your directory by using the |
filename |
Character. YML filename with your credentials. |
env |
Character. Environment variable name. No need to set differently for any function that uses this library. Only for external use. |
... |
Additional parameters. |
Value
List. Result of reading your credential's YML file, filtered by your
from
input if provided.
Set the default directory
The first time you use any function that has the creds
parameter, if
the dir
parameter is set to NA
, this function will ask you to
set the directory where you save your YML local file with your credentials.
This will be asked once and will be set for further R sessions. Remember to
reset your session for this setup to start working properly.
YML file format
A YML file is a text file, with .yml
file format. You may start from
the dummy YML file shared which shows the structure you must follow to set your
credentials file. Check it out
here
or find it locally using system.file("docs", "config.yml", package = "lares")
.
See Also
Other Tools:
autoline()
,
bind_files()
,
bring_api()
,
chr2num()
,
db_download()
,
db_upload()
,
export_plot()
,
export_results()
,
files_functions()
,
font_exists()
,
formatColoured()
,
formatHTML()
,
glued()
,
grepm()
,
h2o_selectmodel()
,
haveInternet()
,
image_metadata()
,
importxlsx()
,
ip_data()
,
json2vector()
,
list_cats()
,
listfiles()
,
mail_send()
,
markdown2df()
,
move_files()
,
msplit()
,
myip()
,
quiet()
,
read.file()
,
statusbar()
,
tic()
,
try_require()
,
updateLares()
,
warnifnot()
,
what_size()
Other Credentials:
db_download()
,
db_upload()
,
get_tweets()
,
mail_send()
,
queryDB()
,
queryGA()
,
slackSend()
,
stocks_file()
Examples
## Not run:
# Load dummy config.yml file from the library
# Recommendation: set dir with NA (read documentation)
# We need the directory, not the file
yml <- dirname(system.file("docs", "config.yml", package = "lares"))
# Let's see which credentials we have in our file
get_credentials(dir = yml)
# Warning message: No credentials for NA found in your YML file.
# Try any of the following: 'service1', 'service2', 'service3'
# Get credentials for service2
get_credentials("service2", dir = yml)
## End(Not run)