RStudio Connect Pins, RMarkdown

Hi all, I'm trying to publish a flexdashboard to my company's rsconnect.

According to the documentation, in order to use pins from RSConnect one has to register the board first with something like

board_register_rsconnect(
  name = "rsconnect", 
  key = Sys.getenv("CONNECT_API_KEY"),
  server = Sys.getenv("CONNECT_SERVER"))

without which RSConnect throws an error that the pinboard is not available:

pin_get(name = "fmi", board = "local")

Error from RSConnect:

Error: pin 'fmi' not found in 'local' board

and

pin_get(name = "fmi", board = "rsconnect")

Error: Board 'rsconnect' not a board, available boards: local, packages

Ok, fair enough.

But for some reason, neither Sys.gentenv("CONNECT_API_KEY") nor keyring::key_get("CONNECT_API_KEY") seem to work on RSconnect; they work in my environment just fine, but not when publishing. The error returned is

Error: Invalid API key, the API key is empty.

Passing the explicit key does work, so the issue is not with the API key itself. The key and the server are stored in my ~/.Renviron file, and I use them without problems for a variety of other solutions (including publishing non-pin stuff to RSconnect).

The only thing it seems to work is for non-interactive RMarkdown files but not for dynamic ones.

Any help welcome.

In RStudio Connect, did you already define for you app the environment variable ?
It is in the app setting - publish once first, then set the env var and the app will rerun.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

I would say this is because you do not specifically want to make your API KEY available by default in all your applications. You could also have several API KEYS defined - it is considered good practice to have one API KEY per usage.

From:

The best practice is to create a new API Key for each external tool that needs access to content hosted on RStudio Connect, and to give each Key a name that helps you identify the tool that uses it. When the tool no longer needs access, or if you cannot trust the Key at any time, you can quickly revoke access by deleting the Key.

However, I see how it could feel weird.

1 Like

Wait what? I have to attach the RSconnect API as an environment variable to the same platform that grants me the API in the first place? That feels... weird.

It is the right solution anyway. Thanks.