Movatterモバイル変換


[0]ホーム

URL:


Authentication with rtoot

Obtain and use a token

When a function inrtoot can’t find a valid token onyour computer, it automatically starts authentication. If you want tostart the process manually, you can do so by calling:

library(rtoot)auth_setup()

By default, the token is stored in a directory R has determined tomake sense for you and it is called “rtoot_token.rds”. So you do notneed to worry about it if you are only usingrtoot on yourlocal machine and you are only using one token.

If you do not change thepath argument ofauth_setup() the tokens get stored in the location returnedbytools::R_user_dir("rtoot", "config"). Look there, if youwant to copy a token to a different computer (ideally in the directoryreturned bytools::R_user_dir("rtoot", "config") on the newmachine).

If you want to use multiple tokens, you should change the name of thefile the token is saved in:

auth_setup(name ="account1")

To use this token, you can either read it into your environment andprovide it to each function:

token<-readRDS(file.path(tools::R_user_dir("rtoot","config"),"account1.rds"))get_status(id ="109297677620300632",instance ="mastodon.social",token = token)

Or you can set the default token in the options at the start of asession:

options("rtoot_token"=file.path(tools::R_user_dir("rtoot","config"),"account1.rds"))

Environment variable

For advanced users, you can also store your token as an environmentvariable (envvar). You can either obtain a token by calling

auth_setup(clipboard =TRUE)

Or, if you already have a token

token<-readRDS(file.path(tools::R_user_dir("rtoot","config"),"account1.rds"))content<-convert_token_to_envvar(token)

Paste the content from clipboard to your configuration file. If youdon’t have access to clipboard, inspectcontent.


[8]ページ先頭

©2009-2025 Movatter.jp