简体   繁体   中英

Remove the web apps from the G Suite Admin Console by using Google Apps Script

Suppose I have list of web apps in G Suite Admin console. I want to remove the web apps from the list. I know i can remove my web app from admin console one by one.
But I want to remove (or revoke) the web apps using Google Apps Script. Can we do it?

Will this code do the trick?

var res = UrlFetchApp.fetch(https://accounts.google.com/o/oauth2/revoke?token=" + ScriptApp.getOAuthToken());
Logger.log(res.getResponseCode());

The code that is included in the question will not do "the trick".

You need to use the G Suite Admin SDK Directory API . Fortunately, Google Apps Script has it as an Advanced Service -> Admin SDK Directory Service .

At this time it's not possible to uninstall / revoke domain-wide installed apps but it's possible to do this on a user by user basis.

By using this service, first you should get a list of the domain users, then get the tokens. From each token you should get the clientId, then using the user primary email address and the clientId you could delete the token so the web app will not be able to access the user data and do things on behalf the users anymore but bear in mind that they could authorize these apps again unless you disable this permission on the G Suite Admin Console.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM