Pythe1337N / garmin-connect

Makes it simple to interface with Garmin Connect to get or set any data point.
MIT License
144 stars 58 forks source link

Error 429 #32

Open pookdeveloper opened 2 years ago

pookdeveloper commented 2 years ago

Any way to resolve this problem? Unhandled rejection StatusCodeError: 429 - "<!DOCTYPE html>\n<!--[if lt IE 7]> <html class=\"no-js ie6 oldie\" lang=\"en-US\"> <![endif]-->\n<!--[if IE 7]> <html class=\"no-js ie7 oldie\" lang=\"en-US\"> <![endif]-->\n<!--[if IE 8]> <html class=\"no-js ie8 oldie\" lang=\"en-US\"> <![endif]-->\n<!--[if gt IE 8]><!--> <html class=\"no-js\" lang=\"en-US\"> <!--<![endif]-->\n<head>\n<title>Access denied | sso.garmin.com used Cloudflare to restrict access</title>\n<meta charset=\"UTF-8\" />\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge,chrome=1\" />\n<meta name=\"robots\" content=\"noindex, nofollow\" />\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n<link rel=\"stylesheet\" id=\"cf_styles-css\" href=\"/cdn-cgi/styles/main.css\" type=\"text/css\" media=\"screen,projection\" />\n\n\n<script type=\"text/javascript\">\n(function(){if(document.addEventListener&&window.XMLHttpRequest&&JSON&&JSON.stringify){var e=function(a){var c=document.getElementById(\"error-feedback-survey\"),d=document.getElementById(\"error-feedback-success\"),b=new XMLHttpRequest;a={event:\"feedback clicked\",properties:{errorCode:1015,helpful:a,version:1}};b.open(\"POST\",\"https://sparrow.cloudflare.com/api/v1/event\");b.setRequestHeader(\"Content-Type\",\"application/json\");b.setRequestHeader(\"Sparrow-Source-Key\",\"c771f0e4b54944bebf4261d44bd79a1e\");\nb.send(JSON.stringify(a));c.classList.add(\"feedback-hidden\");d.classList.remove(\"feedback-hidden\")};document.addEventListener(\"DOMContentLoaded\",function(){var a=document.getElementById(\"error-feedback\"),c=document.getElementById(\"feedback-button-yes\"),d=document.getElementById(\"feedback-button-no\");\"classList\"in a&&(a.classList.remove(\"feedback-hidden\"),c.addEventListener(\"click\",function(){e(!0)}),d.addEventListener(\"click\",function(){e(!1)}))})}})();\n</script>\n\n<script defer src=\"https://api.radar.cloudflare.com/beacon.js\"></script>\n</head>\n<body>\n <div id=\"cf-wrapper\">\n <div class=\"cf-alert cf-alert-error cf-cookie-error hidden\" id=\"cookie-alert\" data-translate=\"enable_cookies\">Please enable cookies.</div>\n <div id=\"cf-error-details\" class=\"p-0\">\n <header class=\"mx-auto pt-10 lg:pt-6 lg:px-8 w-240 lg:w-full mb-15 antialiased\">\n <h1 class=\"inline-block md:block mr-2 md:mb-2 font-light text-60 md:text-3xl text-black-dark leading-tight\">\n <span data-translate=\"error\">Error</span>\n <span>1015</span>\n </h1>\n <span class=\"inline-block md:block heading-ray-id font-mono text-15 lg:text-sm lg:leading-relaxed\">Ray ID: 6e8dabfb5f7569de &bull;</span>\n <span class=\"inline-block md:block heading-ray-id font-mono text-15 lg:text-sm lg:leading-relaxed\">2022-03-08 18:35:38 UTC</span>\n <h2 class=\"text-gray-600 leading-1.3 text-3xl lg:text-2xl font-light\">You are being rate limited</h2>\n </header>\n\n <section class=\"w-240 lg:w-full mx-auto mb-8 lg:px-8\">\n <div id=\"what-happened-section\" class=\"w-1/2 md:w-full\">\n <h2 class=\"text-3xl leading-tight font-normal mb-4 text-black-dark antialiased\" data-translate=\"what_happened\">What happened?</h2>\n <p>The owner of this website (sso.garmin.com) has banned you temporarily from accessing this website.</p>\n \n </div>\n\n \n </section>\n\n \n <div class=\"feedback-hidden py-8 text-center\" id=\"error-feedback\">\n <div id=\"error-feedback-survey\">\n Was this page helpful?\n <button class=\"border border-solid bg-white cf-button cursor-pointer ml-4 px-4 py-2 rounded\" id=\"feedback-button-yes\" type=\"button\">Yes</button>\n <button class=\"border border-solid bg-white cf-button cursor-pointer ml-4 px-4 py-2 rounded\" id=\"feedback-button-no\" type=\"button\">No</button>\n </div>\n <div class=\"feedback-success feedback-hidden\" id=\"error-feedback-success\">\n Thank you for your feedback!\n </div>\n </div>\n \n\n <div class=\"cf-error-footer cf-wrapper w-240 lg:w-full py-10 sm:py-4 sm:px-8 mx-auto text-center sm:text-left border-solid border-0 border-t border-gray-300\">\n <p class=\"text-13\">\n <span class=\"cf-footer-item sm:block sm:mb-1\">Cloudflare Ray ID: <strong class=\"font-semibold\">6e8dabfb5f7569de</strong></span>\n <span class=\"cf-footer-separator sm:hidden\">&bull;</span>\n <span class=\"cf-footer-item sm:block sm:mb-1\"><span>Your IP</span>: 83.143.108.20</span>\n <span class=\"cf-footer-separator sm:hidden\">&bull;</span>\n <span class=\"cf-footer-item sm:block sm:mb-1\"><span>Performance &amp; security by</span> <a rel=\"noopener noreferrer\" href=\"https://www.cloudflare.com/5xx-error-landing\" id=\"brand_link\" target=\"_blank\">Cloudflare</a></span>\n \n </p>\n</div><!-- /.error-footer -->\n\n\n </div><!-- /#cf-error-details -->\n </div><!-- /#cf-wrapper -->\n\n <script type=\"text/javascript\">\n window._cf_translation = {};\n \n \n</script>\n\n</body>\n</html>\n" at new StatusCodeError ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request-promise-core/lib/errors.js:32:15]()) at Request.plumbing.callback ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request-promise-core/lib/plumbing.js:104:33]()) at Request.RP$callback [as _callback] ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request-promise-core/lib/plumbing.js:46:31]()) at self.callback ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request/request.js:185:22]()) at onRequestComplete ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/cloudscraper/index.js:629:3]()) at onCloudflareResponse ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/cloudscraper/index.js:251:3]()) at onRequestResponse ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/cloudscraper/index.js:205:5]()) at Request.<anonymous> ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/cloudscraper/index.js:149:7]()) at Object.onceWrapper (node:events:510:26) at Request.emit (node:events:390:28) at Request.<anonymous> ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request/request.js:1154:10]()) at Request.emit (node:events:390:28) at IncomingMessage.<anonymous> ([/Users/davidgarcia/Desktop/garmin-nodejs/node_modules/request/request.js:1076:12]()) at Object.onceWrapper (node:events:509:28) at IncomingMessage.emit (node:events:402:35) at endReadableNT (node:internal[/streams/readable:1343:12]()) at processTicksAndRejections (node:internal[/process/task_queues:83:21]()) node_modules/bluebird/js/release/debuggability.js:954

Thanks

HisashiASM commented 2 years ago

This happens when you recreate a session too many times and Cloudflare prevents you from reconnecting for a period of time. There is no way to get around this at the time, and if you would please, look into the "Reusing your Session" part of the Wiki to mitigate it mostly (sessions will only last for one hour after they are created, and need to be stored on a case to case basis, I use JSON). You can also catch if it throws an Unhandled Rejection and prevent the application from running forward as it will just report null data.

chwassme commented 2 years ago

How long is this "period of time"?