简体   繁体   中英

How to use authenticate a user for google sheets api on a remote server using Node.js?

I am working with Google sheets and node.js and I am able to authorize a user locally and get auth data using cmd using this tutorial https://developers.google.com/sheets/api/quickstart/nodejs but cant authorize it on a remote server like Heroku so I have found an example https://codelabs.developers.google.com/codelabs/sheets-api/#4 but can't really grasp how to implement it in this example https://developers.google.com/sheets/api/quickstart/nodejs .

Thanks in Advance!!

Depending on your requirements and architecture, it may make sense to write to the spreadsheet using a service account . Here is my code for doing that from NodeJS .

Advantages of service accounts:

  • You don't have to do the OAuth dance (less code, fewer steps for the user).
  • Your code can write to the spreadsheet even when no user has granted OAuth access.

Disadvantage:

  • It's hard to enforce different access for different users, as all writes happen with whatever access you have granted to the service account.

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