-
Create/select a project.
-
Enable the Google Drive API.
-
Go to https://console.developers.google.com/apis/credentials and create a service account for the project.
-
Click Create Credentials -> Service Account -> Type a name for the account -> Create.
-
Click on the newly created account, then the add key button.
-
Select create new and generate the file in JSON.
-
Rename the file
credentials.json
and add it to the project directory. -
Give editing permission to the
client_email
on the folder that you want to control using this script. Thisclient_email
is the one referred to in the JSON file that was generated.
- Follow steps 6-9 to give the service account authorization to manage the google drive.
To add write permissions to a list of email addresses
node index.js -a gdriveFileName ./pathToTextFileWithEmails.txt
To remove write permissions to a list of email addresses:
node index.js -r gdriveFileName ./pathToTextFileWithEmails.txt
To get an example of the arguments to use:
node index.js -h