Skip to content


User meta-data#

Plumber APIs can access the username and the names of groups of the current logged in user by parsing the RStudio-Connect-Credentials request header.


Your Plumber API should use the HTTP_RSTUDIO_CONNECT_CREDENTIALS name to obtain the RStudio-Connect-Credentials header value. All HTTP headers are made available on the req request object using a normalized name prefixed with HTTP_.

This simple Plumber API defines a /hello route that greets the arriving user.


# Returns a list containing "user" and "groups" information 
# populated by incoming request data.
getUserMetadata <- function(req) {
    if (!is.null(rawUserData)) {
    } else {

#* @get /hello
function(req, res){
    user <- getUserMetadata(req)
    username <- user[["user"]]
    if (!is.null(username)) {
        return(list(message = paste0("So nice to see you, ", username, ".")))
    } else {
        return(list(message = paste0("Howdy, stranger.")))

User and Group uniqueness#

Most environments have unique usernames where each user identifies a single user and groups the name of the groups the user is a member of.

However, in large organizations with hundreds of users and groups, this may not be true. See the Admin Guide sections Credentials for Content for more information.