我已经阅读了Google电子表格文档https://developers.google.com/sheets/api/guides/authorizing,它说,如果文档是公开的,则不需要Oauth 2.0,并且API key 就足够了。我正在尝试使用hurl和api键作为parameter.it发出测试请求,但是它仍然给我错误,我需要使用Oauth,有什么想法吗?
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 key 还不够。您正在尝试使用需要OAuth授权的spreadsheets.values.append:
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。
关于google-sheets - 无需Oauth token 即可访问Google电子表格API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48747530/