Put permissions on a sheet when create a spreadsheet with Google API


I am using Google’s Spreadsheets API in NodeJS and I know how I can create a Spreadsheet with the following code

const auth = new GoogleAuth({
    keyFile: 'src/credentials.json',
    scopes: "https://www.googleapis.com/auth/spreadsheets"
})

const client = await auth.getClient()

const googleSheets = google.sheets({version:"v4", auth: client})

let resource = {
    properties: {
        title: 'Test'
    },
}

googleSheets.spreadsheets.create(
    {
        resource,
        fields: 'spreadsheetId'
    }, 
    (err, spreadsheet) =>{
        if (err) {
          console.log(err);
        } else {
          console.log(`${JSON.stringify(spreadsheet)}`);
        }
    }
)

This returns the ID of the Spreadsheet and more information, but my problem is that as much as I have searched, I have not found how to give permissions to an email to access the Spreadsheet.

Source: JavaSript – Stack Overflow

November 1, 2021
Category : News
Tags: google-api-nodejs-client | javascript | node.js | permissions | spreadsheet

Leave a Reply

Your email address will not be published. Required fields are marked *

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.