Is there a way to remove access to Third-party apps & services with a function from App Script?
From the same Spreadsheet that requested access, to run scripts.
I would like to run a script (function) to remove access for that spreadsheet, instead of going to Google Account > Data & privacy > Third-party apps & services
to show what I need, I will show the entire process from request access to remove it
allowing script to run
and to revoke, you would need to go to:
Google Account > Third-party apps & services
and individually
remove access
searching I found how to remove editors, etc but not what I was looking for or what seems to be deprecated function like getAuthorization()
function revokeAccessToSpreadsheet() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var currentSheetId = ss.getId();
var authorization = ScriptApp.getAuthorization(currentSheetId);
authorization.revoke();
}
Moving this to an answer per the comments.
To invalidate authentication programmatically, you can use invalidateAuth.
Note that this invalidates all auth on a given file wholesale.