Skip to main content
Question

BoxSharedLink with password

  • May 22, 2025
  • 3 replies
  • 26 views

Forum|alt.badge.img
Hey there, 
I'm trying to share files an folders using the SDK api,
How i can add a password to the shared link.

String folderId = boxFolderId;
BoxFolder file = new BoxFolder(apiConnection, folderId);
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.OPEN,null, permissions);

Thanks for help.

3 replies

Forum|alt.badge.img

Hi ,

 

Welcome to the Box Community and thanks for your first post in the forum!

 

Thanks for the detailed question! Have you checked out the developer documentation here for reference?

 

I see some example code here:

 

{
  "url": "https://www.box.com/s/vspke7y05sb214wjokpk",
  "download_url": null,
  "vanity_url": null,
  "is_password_enabled": false,
  "unshared_at": null,
  "download_count": 0,
  "preview_count": 0,
  "access": "open",
  "permissions": {
    "can_download": true,
    "can_preview": true
  }
}

Be sure to read our guidelines, Subscribe to content you like, and complete your profile on the community.

 


Forum|alt.badge.img

Hi  — I'm Matt, the technical lead for our SDKs.  The Java SDK includes an overload of the createSharedLink method that lets you set a password as of v2.21.0 — please upgrade your version of the SDK to take advantage of this functionality.  You should be able to do the following:

 

String folderId = boxFolderId;
BoxFolder file = new BoxFolder(apiConnection, folderId);
BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions();
permissions.setCanDownload(true);
permissions.setCanPreview(true);
String password = "PASSWORD GOES HERE";
BoxSharedLink sharedLink = file.createSharedLink(BoxSharedLink.Access.OPEN,null, permissions, password);

Forum|alt.badge.img

Thanks for yout help Mwiller, it works, 

 

I have an other question, how can i share multiple files and folders ?