Skip to main content
Question

how to access a file anonymously via the api?

  • May 21, 2025
  • 2 replies
  • 2 views

Forum|alt.badge.img

Hi!

 

The below code works (when using a BasicClient):

 

router.get('/testBox', function(req, res) {
    console.log("testbox");
    // Create a basic API client 
    var client = sdk.getBasicClient('pEsQejhEGEHH53r5muOhQkCquNBj8ddl');

    client.files.get('***number removed for privacy***463', null, function(err, data) {
        console.log("file:");
        console.log(JSON.stringify(data));
        console.log("err:" + err);

    });
    res.end("testbox");
});

but trying the same thing with an AnonymousClient (the file is public btw) doesn't work:

 

router.get('/testAnon', function(req, res) {
    console.log("testAnon");
    // Create a basic API client 
    var client = sdk.getAnonymousClient();

    client.files.get('***number removed for privacy***463', null, function(err, data) {
        console.log("file:");
        console.log(JSON.stringify(data));
        console.log("err:" + err);

    });
    res.end("testAnon");
});

does NOT work. I have searched the forum and can't find anything that help, any suggestions?

 

Thank you!

 

Mark

 

2 replies

Forum|alt.badge.img

Hi,

 

Anyone have any ideas, didn't think this would be hard...

 

Thanks,

 

Mark


Forum|alt.badge.img

This should work:

 

client.sharedItems.get(
    '',
    null,
    null,
    function(err, data) {
        console.log("file:");
        console.log(JSON.stringify(data));
        console.log("err:" + err);
});