RSTUDIO_USER_IDENTITY in Plumber API on Posit Connect using API Key for authentication

Dear community members,
I make requests to a Plumber API which is hosted on Posit Connect using a Posit Connect API Key for authentication. The API returns that the value of Sys.getenv()["RSTUDIO_USER_IDENTITY"] is empty. I would expect to receive a value for RSTUDIO_USER_IDENTITY, because the API Key is linked to a specific user account.

Why is Sys.getenv()["RSTUDIO_USER_IDENTITY"] empty when connecting to a Plumber API hosted on Posit Connect using a Posit Connect API Key?

Does a workaround exist to find out which user account is linked to the API Key that is being used for the API request?

Example Plumber API:

library(plumber)

#* @get /exampleapi
information <- function(req, res, session) {
  return(Sys.getenv()["RSTUDIO_USER_IDENTITY"][[1]])
}

I believe you can get the information you are looking for using this documentation page:

https://docs.posit.co/connect/user/plumber/index.html#user-meta-data

Thank you! Using HTTP_RSTUDIO_CONNECT_CREDENTIALS was indeed the correct solution.

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.