Your workflow is unique 👨💻 - tell us how you use Dropbox here.
Forum Discussion
AG
9 years agoNew member | Level 1
How can I programmatically control grant access to a shared folder?
I'd like to programmatically (e.g., through JavaScript) grant a user to access a shared dropbox folder. Is that possible? Where can I find more information or sample code?
(Thanks in advance for your help!)
1 Reply
Replies have been turned off for this discussion
- Greg-DB9 years ago
Dropbox Community Moderator
Yes, you can use the API v2 /sharing/add_folder_member endpoint to invite a user to a shared folder. In JavaScript, it would look like this:
$.ajax({
url: 'https://api.dropboxapi.com/2/sharing/add_folder_member',
type: 'POST',
processData: false,
data: JSON.stringify({"shared_folder_id": "84528192421","members": [{"member": {".tag": "email","email": "justin@example.com"},"access_level": {".tag": "editor"}},{"member": {".tag": "dropbox_id","dropbox_id": "dbid:AAEufNrMPSPe0dMQijRP0N_aZtBJRm26W4Q"},"access_level": {".tag": "viewer"}}],"quiet": false,"custom_message": "Documentation for launch day"}),
contentType: 'application/json',
headers: {
"Authorization": "Bearer <ACCESS_TOKEN>"
},
success: function(data) {
console.log(data);
},
error: function(data) {
console.error(data);
}
})<ACCESS_TOKEN> should be replaced with the OAuth 2 access token.
About Dropbox API Support and Feedback
Get help with the Dropbox API from fellow developers and experts.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!