Skip to main content
Question

How to use TokenRestriction?

  • April 30, 2026
  • 0 replies
  • 4 views

Hi,

I’m trying to find a way to restrict a range of files.
Using a down scoped token like this:
 

List<String> scopes = new ArrayList<String>();

scopes.add("item_preview");
scopes.add("item_download");

List<TokenRestriction> restrictions = new ArrayList<>();
for (String id : fileIds) {
String resourceUrl = "https://api.box.com/2.0/files/" + id;
restrictions.add(new TokenRestriction(scopes, resourceUrl));
}
ScopedToken downscopedToken = api.getDownscopedToken(scopes, null, null, restrictions);

boxToken = downscopedToken.getAccessToken();


I can’t find the class of the TokenRestriction.
import com.box.sdk.TokenRestriction;   is not available.
I’m using version 5.9 of the java SDK.
Is there a solution use TokenRestriction or other way to restrict a list of files?

Kind regards,

Marcel
​​​​​​​