I am working on an app where the user authenticates using OAuth. One of the features is that the user should be able to recycle files and restore them.

Recycling and restoring is done using the following methods:

Guid DeleteFile(File file, ClientContext ctx){
    // Set file up for deletion.
    var result = file.ListItemAllFields.Recycle();

    // Delete file.
    Guid recycledId = result.Value;
    return recycledId;

void RestoreFile(Guid recycledId, ClientContext ctx){
    // Get the recycle bin.
    RecycleBinItemCollection recycleBin = ctx.Web.RecycleBin;

    // Restore the item.
    recycleBin.GetById( recycledId ).Restore();

These methods works fine when the context has been authenticated using a token from a standard user since the deleted file is moved to the first stage recycle bin. However if the context has been authenticated using a token from an admin user the item is moved directly to the second stage recycle bin that can only be accessed through ClientContext.Site.RecycleBin. Since I only use the scope Web.Write when getting the token it is not possible to access the second stage recycle bin.

I would rather not increase the scope, so is it in any way possible to force a file to be moved to the first stage recycle bin when the user is an admin?

Using the SharePoint Online website it seems that all files deleted by an admin are automatically moved to the second stage recycle bin, so it might very well be that it can't be done. Is there some settings on the site that can be changed?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.