This function will add a TikTok cookie and a user agent to your .Renviron file so it can be called securely without being stored in your code. After you have installed your key, it can be called any time by typing Sys.getenv("TIKTOK_COOKIE") or Sys.getenv("TIKTOK_UA"). If you do not have an .Renviron file, the function will create one for you.

tk_auth(cookie, ua, id_cookie)

Arguments

cookie

The TikTok cookie as string. Find out here how to get a TikTok cookie: https://www.youtube.com/watch?v=kYMV2ugxacs&feature=youtu.be

ua

The User Agent, that should be used when making HTTP requests. Default is 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'

id_cookie

Logged-in cookie used by the comment endpoint (experimental).

Examples

if (FALSE) { # Put in your cookie: tk_auth(cookie = "abcd012345678901234567890123456789") # Restart R for changes to take effect or load your environment so you can use the cookie without # restarting R. readRenviron("~/.Renviron") # You can check it with: Sys.getenv("TIKTOK_COOKIE") }