'This function did not work with me, how i can fix it

This code is based on the answer by @Max Makhrov

This function did not work with me, how I can fix it? I tried this function but "allow access" still appearing.

How to allow access for importrange as explaining in this page How to allow access for importrange function via apps script?

function myFunction(fileId, donorId) {
  var fileId = ('1p0VQQT6CQ1hFYy4sShuXfm9B-ukgvSf92FC7XmRvM0Y');
  var donorId = ('1QSjlFX95gbtRHP9n-1cS0X0yIDT17JvP8mPe-FpViww');
  // adding permission by fetching this url
  var url = 'https://docs.google.com/spreadsheets/d/' + fileId + '/externaldata/addimportrangepermissions?donorDocId=' + donorId;
  var token = ScriptApp.getOAuthToken();
  var params = { method: 'post', headers: { Authorization: 'Bearer ' + token, }, muteHttpExceptions: true };
  UrlFetchApp.fetch(url, params);
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source