google-sheets - 使用 node.js 为开发人员设置 Google 表格,在允许我的 API 查看我的电子表格后,它重定向到“找不到页面”
问题描述
我正在尝试让Google Sheets API与 node 一起使用,并且到目前为止,它要求我使用我的 Google 帐户对其进行签名,并允许该应用程序查看我的 Google 电子表格。在我按下允许后,它会将我重定向到找不到显示“ERR_CONNECTION_REFUSED”的页面。在 URL 中,它显示为“code=4”,但我找不到它代表什么。我目前被困在控制台中,等待此页面的代码。.
我的代码与 API 文档中的代码完全相同,但我不得不将“credentials.installed”更改为“credentials”,否则它不起作用。
这可能与我的回调 URI 有关吗?我将“授权的 JavaScript 来源”和授权的重定向 URI 都作为“http://localhost:8080”。
我的 credentials.JSON 看起来像这样
{
"client_id":"XXXX",
"project_id":"XXXX","auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"XXXX",
"redirect_uris":["http://localhost:8080"],
"javascript_origins":["http://localhost:8080"]
}
总而言之:在我按下“接受”按钮后,我得到一个“找不到页面”而不是您应该粘贴到控制台的代码。
解决方案
我选择了“Web 应用程序”而不是“桌面应用程序”。只需从快速启动下载凭证 JSON 并直接复制代码即可。我的错。
推荐阅读
- c# - ChromeDriver / Selenium 不允许 gmail 登录
- python - psycpg2 插入失败
- php - PHP表单为2个不同的字段输入相同的值
- html - 通过单击背景来防止模式被隐藏是否违反了可访问性要求?
- excel - 需要关于嵌套 If 函数的指导
- reactjs - React-Apollo-Hooks 使用Mutation 传递空变量?
- swagger - 合并多个 swagger 文件
- python - 运行使用多个 conda 环境的烧瓶应用程序
- android - 如何使用 Jetpack Compose 请求权限?
- node.js - 无法使用 jest 和 ts-jest 使用静态方法模拟类