折腾Google Docs API 的坑

举报
拿我格子衫来 发表于 2022/03/17 23:07:15 2022/03/17
1.5k+ 0 0
【摘要】 google docs api 起步 有关链接   快速开始  https://developers.google.cn/docs/api/quickstart/nodejs#step_2_install_the_client_library 官方代码:https://github.com/gsu...

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上的代码下载下来

记得执行 安装相应的包

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' } }

文章来源: fizzz.blog.csdn.net,作者:拿我格子衫来,版权归原作者所有,如需转载,请联系作者。

原文链接:fizzz.blog.csdn.net/article/details/96605130

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

作者其他文章

评论(0

抱歉,系统识别当前为高风险访问,暂不支持该操作

    全部回复

    上滑加载中

    设置昵称

    在此一键设置昵称,即可参与社区互动!

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

    *长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。