无法将 google 日历与 ESP32 集成...?

Can't able to integrate google calendar with ESP32...?

你好,我正在尝试通过 esp32 获取日历事件,我正在使用 NodeMCU 固件和 Lua(5.1) (Nodemcu: https://nodemcu.readthedocs.io/en/dev-esp32/modules/http/) 我写的所有内容都正确google 相同的脚本并在两种情况下使用 chrome 和邮递员进行测试 url 工作正常但是当使用 esp32 尝试时它不是......我无法调试自己,帮助我调试问题。

这是我一直在尝试的代码

headers = {["Content-Type"] = "application/json", ["Host"]="script.google.com",["Accept"]= "application/json, text/plain, /" ,}
connection = http.createConnection("https://script.google.com/macros/s/AKfycbybO_1kyXTxTOAJ8d4X0niOs-7y58TIfBhD92ThMuh8GJ/exec", http.GET, { headers=headers } )
connection:on("data", function(status,data)
  print("data =", status,data)
end)
connection:request()

我得到的错误是

<HEAD>
<TITLE>Moved Temporarily</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<H1>Moved Temporarily</H1>
The document has moved <A HREF="https://script.googleusercontent.com/macros/echo?user_content_key=S3EjAkUDuxNdm-9dm2FVF3DWmazC_Qh0BGbIh1FAM_v_VkANvqPIszl-v-NCgqVk-jzU4NDO6FSjYkUTckVub_o2vxQNHFTUm5_BxDlH2jW0nuo2oDemN9CCS2h10ox_1xSncGQajx

data =  404 <!DOCTYPE html><html lang="en"><head><meta name="description" content="Web word processing, spreadsheets and presentations"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"><link rel="shortcut icon" href="//docs.google.com/favicon.ico"><title>Page not found</title><meta name="referrer" content="origin"><link href="//fonts.googleapis.com

data =  404 /css?family=Product+Sans" rel="stylesheet" type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw"><style nonce="BbT+xY6IwnjihR7Y0w7wAw">/* Copyright 2021 Google Inc. All Rights Reserved. */
.goog-inline-block{position:relative;display:-moz-inline-box;display:inline-block}* html .goog-inline-block{display:inline}*:first-child+html .goog-inline-block{display:inline}#drive-logo{margin:

data =  404 18px 0;position:absolute;white-space:nowrap}.docs-drivelogo-img{background-image:url('//ssl.gstatic.com/images/branding/googlelogo/1x/googlelogo_color_116x41dp.png');background-size:116px 41px;display:inline-block;height:41px;vertical-align:bottom;width:116px}.docs-drivelogo-text{color:#000;display:inline-block;opacity:0.54;text-decoration:none;font-family:'Product Sans',Arial,Helvetica,sans-serif;font-size:32px;text-rendering:optimizeLegibility;position:relative;top:-6px;left:-7px;-webkit-font-smoothing:an

data =  404 tialiased;-moz-osx-font-smoothing:grayscale}@media (-webkit-min-device-pixel-ratio:1.5),(min-resolution:144dpi){.docs-drivelogo-img{background-image:url('//ssl.gstatic.com/images/branding/googlelogo/2x/googlelogo_color_116x41dp.png')}}</style><style type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw">body {background-color: #fff; font-family: Arial,sans-serif; font-size: 13px; margin: 0; padding: 0;}a, a:link, a:visited {color: #112ABB;}</style><style type="text/css" nonce="BbT+xY6IwnjihR7Y0w7wAw">.errorMessage 

data =  404 {font-size: 12pt; font-weight: bold; line-height: 150%;}</style></head><body><div id="outerContainer"><div id="innerContainer"><div style="position: absolute; top: -80px;"><div id="drive-logo"><a href="/"><span class="docs-drivelogo-img" title="Google logo"></span><span class="docs-drivelogo-text">&nbsp;Drive</span></a></div></div><div align="center"><p class="errorMessage" 

data =  404 style="padding-top: 50px">Sorry, unable to open the file at present.</p><p> Please check the address and try again.</p><div style="background: #F0F6FF; border: 1px solid black; margin-top: 35px; padding: 10px 125px; width: 300px;"><p><strong>Get stuff done with Google Drive</strong></p><p>Apps in Google Drive make it easy to create, store and share online documents, spreadsheets, presentations and more.</p><p>Learn more at <a href="https://drive.google.com/start/apps">drive.google.com/start/apps</a>.</p></d

data =  404 iv></div></div></div></body><style nonce="BbT+xY6IwnjihR7Y0w7wAw">html {height: 100%; overflow: auto;}body {height: 100%; overflow: auto;}#outerContainer {margin: auto; max-width: 750px;}#innerContainer {margin-bottom: 20px; margin-left: 40px; margin-right: 40px; margin-top: 80px; position: relative;}</style></html>

我尝试了不同的 headers 但没有用,我尝试将数据上传到 google 传播 sheet。同样的问题 url 与浏览器、Postman 和 与 esp32 一起工作,它正在上传数据到 spreadsheet 但错误是相同的(404)。我不明白为什么....

您好,我找到了解决方案,首先问题出在 ESP32 http 请求上,http 缓冲区大小较小,这就是为什么在重定向后,身份验证令牌未完全接收(默认为 512 字节不足),因此无法接收能够发出该请求(无法将令牌重定向到 google)并给出 404 错误。增加缓冲区后它起作用了。在下面的代码中,将缓冲区大小更新为 2048

connection=http.createConnection("https://script.google.com/macros/s/AKfycbyg3q6yhMQGWmPPH2e95/exec",  http.GET,{bufsz=2048} )
connection:on("data", function(status,data)
  print("data returned =", status,data)
end)
connection:on("complete", function(status)
  print("Request completed with status code =", status)
end)
connection:request()

如果有人想要我可以分享详细信息...