简体   繁体   中英

Import private data into Google Spreadsheet

I am importing private data into Google Spreadsheet using the function ImportXML. To make this work, I have written an API. However, since the data in private I would like to make the API private. I can do that. The problem is to do it in a way so that Google Spreadsheet can communicate with my custom API.

Preferably, I would like to use OAuth 2.0 with the user logged into Google Spreadsheet. Is this possibly?

Other suggestions are welcome.

This is possibly. First, make your custom API use Google auth.

In a Google Apps Script in your Google Spreadsheet

  1. Fetch the URI to initialize auth with your API
  2. Follow the redirect

Doing these two steps you recieve some kind of token to prove you are logged in. Use this then contacting the API for data.

Be advised, if you use an installed app, the user authenticating will be the one who installed the app, not the one opening the spreadsheet. If you do not use an installed app, you can not do this automatically then you open the spreadsheet because non-installed apps cannot authenticate in the onOpen() method. So you would have to use a menu item, a buttom or whatever to execute the function manually.

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