前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >折腾Google Docs API 的坑

折腾Google Docs API 的坑

作者头像
拿我格子衫来
发布2022-01-24 09:56:45
发布2022-01-24 09:56:45
1.3K00
代码可运行
举报
文章被收录于专栏:TopFETopFE
运行总次数:0
代码可运行

google docs api

起步

有关链接

快速开始 https://developers.google.cn/docs/api/quickstart/nodejs#step_2_install_the_client_library

官方代码:https://github.com/gsuitedevs/node-samples/blob/master/docs/quickstart/index.js

登录谷歌账号后 否则后面的按钮点击后没有反应的

打开https://developers.google.com/docs/api/quickstart/nodejs

点击

获取api使用凭据

点击按钮后会显示

然后点击下载凭据 保存到项目中

等下运行程序会读取这个文件

把github上的代码下载下来

记得执行 安装相应的包

代码语言:javascript
代码运行次数:0
运行
复制
npm install googleapis --save

运行 node index.js

会出现以下信息

这个时候就要点击链接 进行屏幕授权 ,会让你选择谷歌账号登录,直接即可

复制代码到控制台

在这一步复制后 我的机器会报错 暂时不知道是哪里 出错了, 等知道了再来补充博客 告诉大家

错误信息如下:

Error retrieving access token { FetchError: request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 216.58.200.42:443 at ClientRequest.<anonymous> (E:\Main_Pro\alone_end\node_modules\node-fetch\lib\index.js:1455:11) at ClientRequest.emit (events.js:182:13) at TLSSocket.socketErrorListener (_http_client.js:392:9) at TLSSocket.emit (events.js:182:13) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19) message: 'request to https://oauth2.googleapis.com/token failed, reason: connect ETIMEDOUT 216.58.200.42:443', type: 'system', errno: 'ETIMEDOUT', code: 'ETIMEDOUT', config: { method: 'POST', url: 'https://oauth2.googleapis.com/token', data: 'code=4%2FigG7rqa-jhZqD8_y0XlVYV1GBWvpM0cMD0PcpbplpqL7rl5izNZ2k2I&client_id=285039265577-dagtjbu87m24s42onh4brm5558d9c11r.apps.googleusercontent.com&client_secret=Juxcapb4OYeOKewyPA3VuvaH&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=', headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'User-Agent': 'google-api-nodejs-client/4.2.5', Accept: 'application/json' }, params: [Object: null prototype] {}, paramsSerializer: [Function: paramsSerializer], body: 'code=4%2FigG7rqa-jhZqD8_y0XlVYV1GBWvpM0cMD0PcpbplpqL7rl5izNZ2k2I&client_id=285039265577-dagtjbu87m24s42onh4brm5558d9c11r.apps.googleusercontent.com&client_secret=Juxcapb4OYeOKewyPA3VuvaH&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=', validateStatus: [Function: validateStatus], responseType: 'json' } }

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • google docs api
  • 起步
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档