无需Oauth令牌即可访问Google电子表格API [英] Access Google spreadsheet API without Oauth token
问题描述
我已经阅读了Google电子表格文档 https://developers.google.com/sheets/api/guides/authorization 它说,如果文档是公开的,则不需要Oauth 2.0,API密钥就足够了.我正在尝试使用hurl和api键作为parameter.it发出测试请求,但是它仍然给我错误,我需要使用Oauth,有什么想法吗?
I've read google spreadsheet documentation https://developers.google.com/sheets/api/guides/authorizing And it says, that if document is public, you don't need Oauth 2.0 and API key is sufficient. I'm trying to do a test request with hurl and api key as parameter.it, but it still gives me error, that I need to use Oauth, any thoughts?
POST https://sheets.googleapis.com/v4/spreadsheets/16woR-nfy6KYBbkQpC2YOT1GzIean8rTzjueUnlzLMiE/values/Sheet1!A1:E1:append?valueInputOption=USER_ENTERED
响应:
"error": {"code": 401,"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.","status": "UNAUTHENTICATED"}
推荐答案
API密钥不足.您正在尝试使用 spreadsheets.values.append ,需要OAuth授权:
API key is not enough. You're trying to use spreadsheets.values.append which requires OAuth authorization:
授权需要以下OAuth范围之一:
Authorization Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
https://www.googleapis.com/auth/spreadsheets
For more information, see the [Auth Guide](https://developers.google.com/identity/protocols/OAuth2).
请注意它说的是OAuth.
Note it says OAuth.
这篇关于无需Oauth令牌即可访问Google电子表格API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!