'update user permissions of a google sheet using app script

I have a google sheet and i need to update the user permissions as below

  1. Add [email protected] to sheet and give editor access (working with below code )

Drive.Permissions.insert(
   {
     'role': 'writer',
     'type': 'user',
     'value': '[email protected]'
   },
   sourceFileId,
   {
     'sendNotificationEmails': 'false'
   });
  1. For all the users emails apart from [email protected], I need to make them just viewer access

Step -2 Im not able to achieve , please help me.Thanks



Sources

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

Source: Stack Overflow

Solution Source