Sorry that you're having trouble with this. Have you already registered RStudio Connect as a board in this session?
Looking through the Using RStudio Connect Boards vignette, it seems like having multiple servers or accounts available could require additional steps:
If you happen to have multiple RStudio Connect servers registered, you will have to specify the server parameter. Similarly, when multiple accounts are registered, you will need to specify the account parameter.
# register when multiple servers are available
board_register_rsconnect(server = "https://rstudio-connect-server")
# register when multiple accounts are available
board_register_rsconnect(account = "account-name")
That said, I'm not sure why pins::pin_get(paste0("username/", pin_name), board = "rsconnect") would work in this scenario if you hadn't. I'm gonna tag @javierluraschi in, since I'm sure he'll know whether or not you should file this as an issue.
board_register_rsconnect(key = "the-rstudio-connect-api-key",
server = "https://rstudio-connect-server")
or,
board_register_rsconnect(key = Sys.getenv("CONNECT_API_KEY"),
server = Sys.getenv("CONNECT_SERVER"))
(or a more secure way that I don't know about—though I've learned a lot from virtually following your R-security/standup-comedian tour), you also need to have a way to get the username from…somewhere.
At the very least, I'd say this is a hard one to crack from my naïve reading of the documentation. So, at the very least, I think an issue for improved/easier-to-find docs would be warranted.
I'm gonna leave it to you to file, since I don't want to lose nuance, and I know you're an old hand at these things!