cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Check out the Dropbox cheat sheet for getting started in 2021 here!

Dropbox teams & admins

Got a question about your Dropbox Business account? Get help from users like you. Post a question to get started.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Granular sharing permissions via command line

Granular sharing permissions via command line

Explorer | Level 3

If I pay dropbox business/enterprise/whatever:

* Will I have a command to give access to a specific folder to a specific account?

* Will I have a command to give access to a specific files to a specific account?

 

Finally, I wanted to say I d pay an enterprise to be able to use symlinks pointing internally. That would enable granular permission..

 

OS: Linux

1 Accepted Solution

Accepted Solutions

Re: Granular sharing permissions via command line

Collaborator | Level 8

Yes you would be able to do this in the API with:

/add_file_member

/add_folder_member

https://www.dropbox.com/developers/documentation/http/documentation#sharing-add_folder_member

 

You would need to register your app first and authenticate, but it's very easy to do. 

View solution in original post

4 Replies 4

Re: Granular sharing permissions via command line

Collaborator | Level 8

Yes you would be able to do this in the API with:

/add_file_member

/add_folder_member

https://www.dropbox.com/developers/documentation/http/documentation#sharing-add_folder_member

 

You would need to register your app first and authenticate, but it's very easy to do. 

View solution in original post

Re: Granular sharing permissions via command line

Explorer | Level 3
Merci Luke!
Sorry, I didn't have the time yet to to try it out. Hopefully very soon. But your answer looks very promising.
Marc

Re: Granular sharing permissions via command line

Collaborator | Level 8

Just remembered I had this lying around. It's a PHP script I run from my cmd line. Its purpose is to delete files en-masse. All you need to do is replace your token (**YOUR_TOKEN*,  change the API calls to permissions, and likely a few other things. 

 

Thought I'd share as an example, I'm a fairly novice programmer so this is definitely not fully optimized (just realized two auth calls haha).

 

<?php

echo "Enter the path of folder to delete, starting with backslash:";
$handle = fopen ("php://stdin","r");
$line = fgets($handle);
$trimmedline = trim($line);
fclose($handle);

$headers = array("Authorization: Bearer **YOUR_TOKEN**",
                 "Content-Type: application/json");

$ch = curl_init('https://api.dropboxapi.com/2/team/members/list');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "null");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

curl_close($ch);

$json_a=json_decode($response,true);
$getit = $json_a['members'];

foreach ($getit as $result){
  $result2 = $result['profile']['team_member_id'];
  $headers = array("Authorization: Bearer **YOUR_TOKEN**",
                   "Content-Type: application/json",
                   'Dropbox-API-Select-User:' . $result2
                   );
//manually enter the path of the folder below
  $data = array("path" => $trimmedline);
  $data_string = json_encode($data);

  $ch = curl_init('https://api.dropboxapi.com/2/files/delete');
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($ch, CURLOPT_POST, true);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $response = curl_exec($ch);

  echo $response ."\r\n" . $result2;
  echo "\r\n";


  curl_close($ch);
}

?>

 

Re: Granular sharing permissions via command line

Explorer | Level 3
thanks a lot Luke.
I finally got back to it and API is indeed the way to go.
The http (curl) in bash will be enough for my needs.
Polls
Are you starting new work habits this year?

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?