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

Time:12-01

Hi I'm trying to get the calendar events through esp32 and I'm using NodeMCU firmware with Lua(5.1) (Nodemcu: https://nodemcu.readthedocs.io/en/dev-esp32/modules/http/) everything I've done correctly I wrote google script for the same and tested with chrome and postman in both cases url worked fine but when tried with esp32 it's not... I can't able to debug myself, help me debugging the issue.

here is the code I've been trying

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()

and the error I'm getting is

<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  title="Google logo"></span><span >&nbsp;Drive</span></a></div></div><div align="center"><p  

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>

I tried different headers but no use use and I tried implementing uploading the data to google spread sheet. Same issue url worked with browser, Postman and with esp32, it's uploading data to spreadsheet but error is same(404). I can't understand why....

CodePudding user response:

Hi I discovered the solution, first the problem is with ESP32 http request, http buffer size is less so that's why after redirecting, the authentication token is not receiving fully (default is 512 bytes insufficient) so it can't able to make that request(can't able to redirect token to google) giving 404 error. After increasing the buffer it worked. In the below code updated buffer size to 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()

If anybody wants I can share detailed info...

  • Related