You have two options to obtain auth
- The google-drive-uploader package provides its own authentication method: simply define
const auth = await upload.authenticate({
email: 'EMAIL',
privateKey: 'PRIVATE KEY'
});
- The conventional Google libray method is
const {JWT} = require('google-auth-library');
const auth = new JWT(
'EMAIL',
null,
'PRIVATE KEY',
['https://www.googleapis.com/auth/drive']
);
await auth.authorize();
For both options, a privateKey is a credential that you obtain when creating a service account
In other words, to use this ppackage, you need to create a Google Service account, as described here
- When working with a service account,
EMAIL
is the email of the service account - not your own email
- When using a service account - you should give to the service account access to your drive - if you want it to upload files to your drive
- Alternatively you can use impersonation in combination with domain-wide delegation
- The latter allows the service account to act as "you", so you do not need to exlicitly share with it your Drive and files
- See here for a sample on how to create a JWT authentication client with impersonation