【发布时间】:2017-05-08 04:51:16
【问题描述】:
我有一个 Google 电子表格,共享为“知道链接的任何人都可以编辑”。我想使用 Google Sheets API v4 执行 PUT 请求来编辑此文档。理想情况下,我希望仅使用 API 密钥而不使用 OAuth2 来执行此操作,因为使用 OAuth 向 Google 进行身份验证对于使用 Xamarin 来说是一件痛苦的事情。此外,这将要求用户每小时输入一次密码,这会破坏可用性。
据推测,requests for public data can be sent using only the API key in the request,不需要 OAuth。这适用于 GET 请求,但是在为 PUT 请求执行此操作时,我得到了 401 响应。 (This unintentionally failed for GET requests before,这让我相信这也适用于 PUT 请求,只要目标文档是公开共享的)。
GET https://sheets.googleapis.com/v4/spreadsheets/{sheetId}/values/Sheet1%21A1%3AJ1?key={myKey} HTTP/1.1
...有效,但是
PUT https://sheets.googleapis.com/v4/spreadsheets/{sheetId}/values/Sheet1%21A1%3AJ1?key={myKey} HTTP/1.1
...产生 401 Unauthorized。
是否有人能够阐明这是否应该可行,或者如何解决它?
【问题讨论】:
标签: c# .net xamarin.ios google-sheets-api