Using the acl_add_collaborator

Hi there,

I have built an app that allows different people in my team to upload multiple documents onto RStudio Connect. I am trying to use the acl_add_collaborator function to add a person who uploaded a certain document onto RStudio Connect a collaborator on that specific document.

Currently how the app works is that a person uploads a document onto RStudio Connect via the app, however in building the app I used the connect api package and because of the api_key that was created by me I am the only one who can make changes to the uploaded document.

Is there any one who can help me in figuring out how to add a person as a collaborator using the acl_add_collaborator function?

1 Like

For sure! Try something like this:

``` r
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>     filter, lag
#> The following objects are masked from 'package:base':
#>     intersect, setdiff, setequal, union
client <- connect()
#> Defining Connect with host:

bnd <- bundle_dir("~/rstudio/connectapi/tests/testthat/examples/static")
#> Bundling directory ~/rstudio/connectapi/tests/testthat/examples/static
item1 <- deploy(client, bnd, "add_collaborator_testing")
#> Getting content endpoint
#> Creating NEW content 302dfef1-e7dd-49a8-b941-f88d752c90fd with name add_collaborator_testing on
#> Uploading bundle
#> Deploying bundle

all_users <- get_users(client)

one_user <- all_users %>% filter(username == "")

one_user_guid <- one_user %>% pull(guid)

item1 %>% 
#> Warning: The `acl_add` function is experimental and subject to change without warning in a future release
#> This warning is displayed once per session.
#> RStudio Connect Task: 
#>   Content GUID: 302dfef1-e7dd-49a8-b941-f88d752c90fd
#>   Task ID: slb1kflUmvqhn4qJ

item1 %>%
#> Warning: The `get_acl` function is experimental and subject to change without warning in a future release
#> This warning is displayed once per session.
#> # A tibble: 2 x 16
#>   email username first_name last_name user_role created_time       
#>   <chr> <chr>    <chr>      <chr>     <chr>     <dttm>             
#> 1 cole… cole     Cole       Arendt    administ… 2017-10-31 20:22:57
#> 2 alex… alex.go… Alex       Gold      administ… 2019-03-18 18:55:08
#> # … with 10 more variables: updated_time <dttm>, active_time <dttm>,
#> #   confirmed <lgl>, locked <lgl>, guid <chr>, app_role <chr>, is_owner <lgl>,
#> #   password <chr>, content_guid <chr>, content_access_type <chr>

Created on 2021-01-20 by the reprex package (v0.3.0)

I hope that helps!! I'm very curious to hear more about how this goes and if you have any questions / suggestions for what could make it easier!

Thank you Cole, works perfectly.

But, the app returns an error for some users who try to add themselves as collaborators using their usernames. Is there a limit to the number of usernames that the functions allows before cutting off the rest? Because the app would show an error and not add the user as a collaborator but, when I logon to Rstudio connect and add the user manually as a collaborator then there are no problems.

Interesting!! What is the error message you are getting? There shouldn't be any truncation of the usernames... but it is possible that there is multiplicity (i.e. a username cole and a username cole2 would conflict if you tried to search for cole, let's say).

In any case, specifics about the error happening would help us debug what is going on!

I checked if the user names were being typed in correctly, and they were. Each user has their personnel number as the username, so no two people will have similar user names.

Ah interesting! It might be good to log what the user's inputs were.

It looks to me like it might be saying that the app in question doesn't exist? / The GUID is bad?

If you go to this URL in your browser, what do you get? Does it take you to the app?

I get an error when I go to this URL:

Oh sorry... I meant replace GUID with your app's GUID. In your image, that is b6ec4c02-d856-479c-bfef-dad77bce485a

You should also replace with the URL for your server.

So you should go to (with replaced):


If nothing shows up, then that GUID is wrong and you should figure out where that GUID came from.

Thanks for all your help Cole. I found where the problem was. The issue was with the code for specifying all_users

bnd <- bundle_static(input$file$datapath)
      content_1 <- deploy(client,bnd,title = paste0(input$pubname, " - ", input$pubmonth, " ", input$pubyear),access_type = "logged_in", "add_collaborator_testing")
      all_users <- get_users(client, page_size = 20,prefix = NULL,limit = 200)
      one_user <- all_users %>% filter(username == input$username)
      one_user_guid <- one_user %>% pull(guid)
      content_1 %>%
1 Like

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.