如何将 API 密钥添加到谷歌电子表格?

编程入门 行业动态 更新时间:2024-10-24 20:22:55
本文介绍了如何将 API 密钥添加到谷歌电子表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我创建了一个谷歌表并使用 URL 将其转换为 JSON.示例:https://spreadsheets.google/feeds/list/SHEETID/od6/public/values?alt=json

我想在这个谷歌表中添加一个 api 密钥.我通过 Google Cloud Platform 生成了一个 API 密钥 - https://console.cloud.google/flows/enableapi?apiid=sheets.googleapis

现在,我如何将此 API 密钥添加到工作表中?请任何人帮忙.

解决方案

我以为你的 端点 https://spreadsheets.google/feeds/list/SHEETID/od6/public/values?alt=json 适用于 Sheets API v3.看到Sheets API v3的官方文档,是这样写的.><块引用>

更新:Google Sheets v3 API 将于 2021 年 6 月 8 日关闭.

针对这种情况,我建议使用 Sheets API v4.如果电子表格是公开共享的,并且您想要从电子表格中检索值,您可以通过 API 密钥使用以下端点.参考

https://sheets.googleapis/v4/spreadsheets/[SPREADSHEETID]/values/[RANGE]?key=[YOUR_API_KEY]

在这种情况下,[SPREADSHEETID][RANGE][YOUR_API_KEY] 是电子表格 ID,范围(您也可以分别使用工作表名称作为 [RANGE].) 和您的 API 密钥.

注意:

使用 API 密钥时,需要公开共享电子表格.请注意这一点.并且,API 密钥不能用于 GET 方法以外的方法.另外,请注意这一点.

参考:

Google 表格 API v3迁移到 Google Sheets API方法:spreadsheets.values.get of SheetsAPI v4

I have created a google sheet and have converted it into JSON using the URL. example: https://spreadsheets.google/feeds/list/SHEETID/od6/public/values?alt=json

I want to add a api key to this google sheet. I have generated a API key though Google Cloud Platform - https://console.cloud.google/flows/enableapi?apiid=sheets.googleapis

Now, how can i add this API key to the sheet?? Please could anyone help.

解决方案

I thought that your endpoint of https://spreadsheets.google/feeds/list/SHEETID/od6/public/values?alt=json is for Sheets API v3. When the official document of Sheets API v3 is seen, it says as follows.

Update: The Google Sheets v3 API will be shut down on June 8, 2021.

From this situation, I would like to propose to use Sheets API v4. If the Spreadsheet is publicly shared and you want to retrieve the values from the Spreadsheet, you can use the following endpoint using the API key. Ref

https://sheets.googleapis/v4/spreadsheets/[SPREADSHEETID]/values/[RANGE]?key=[YOUR_API_KEY]

In this case, [SPREADSHEETID], [RANGE] and [YOUR_API_KEY] are the Spreadsheet ID, the range (you can also use the sheet name as [RANGE].) and your API key, respectively.

Note:

When the API key is used, the Spreadsheet is required to be publicly shared. Please be careful this. And, the API key cannot be used for the methods except for the GET method. Also, please be careful this.

References:

Google Sheets API v3 Migrate to the Google Sheets API Method: spreadsheets.values.get of Sheets API v4

这篇关于如何将 API 密钥添加到谷歌电子表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-18 02:58:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/928404.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密钥   如何将   电子表格   API   到谷歌

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!