小编Ton*_*uth的帖子

谷歌表格 API 请求上的 CORS 授权

我正在尝试通过表格 API 检索基于单元格的提要从谷歌电子表格中读取数据。该电子表格是私有的,所以我使用 oauth 2.0 来授权我的请求。

通过https://spreadsheets.google.com/feeds/spreadsheets检索有关我的驱动器帐户的基本信息工作正常,但是当我尝试通过 XMLHttp GET 请求直接访问我的电子表格中的数据到https://spreadsheets.google .com/feeds/cells

我收到“请求的资源上不存在‘Access-Control-Allow-Origin’标头”错误。

我已经设置了正确的授权令牌

 xhr.setRequestHeader('Authorization', 'Bearer ' + token);
Run Code Online (Sandbox Code Playgroud)

并尝试通过“激活”CORS

 xhr.setRequestHeader('Access-Control-Allow-Credentials', 'true');
Run Code Online (Sandbox Code Playgroud)

无济于事。

有关如何访问此资源的任何提示?

谢谢 !

xmlhttprequest google-sheets cors

4
推荐指数
1
解决办法
8466
查看次数

标签 统计

cors ×1

google-sheets ×1

xmlhttprequest ×1