连接到生产环境后出现 "evernote.Client.getRequestToken" 的 401 错误

401 error with "evernote.Client.getRequestToken" after connecting to production environment

参考文章

https://github.com/evernote/evernote-sdk-js

问题

evernote-sdk-js的README.md说可以通过设置SANDBOX="false"切换到生产环境,所以我设置SANDBOX="false"并连接到生产环境。

连接到生产环境后,当我运行evernote.Client.getRequestToken时,出现401错误

有什么办法可以解决这个问题吗?

错误代码

{"statusCode":401,"data":"<html>\n<head>\n<script>\n  (function() {\n    var request = new XMLHttpRequest();\n    request.open('GET', '/IsLoggedIn.action', true);\n    request.onload = function() {\n      if (this.status === 403) {\n        \n        window.location = '/Login.action?targetUrl='\n          + encodeURIComponent(window.location.pathname);\n      }\n    };\n    request.send();\n  })();\n</script>\n<meta charset=\"utf-8\" />\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=9,chrome=1\" />\n<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\" />\n<link rel=\"Shortcut Icon\" href=\"/favicon.ico?v2\" type=\"image/x-icon\" />\n<link rel=\"stylesheet\" href=\"/redesign/global/css/reset.css\" />\n\n<link rel=\"stylesheet\" href=\"/redesign/global/css/fonts.css\" media=\"all\" />\n\n<link rel=\"stylesheet\" href=\"/redesign/global/css/header.css\" />\n<link rel=\"stylesheet\" href=\"/redesign/global/css/layout.css\" />\n\n<title>Evernote Error</title>\n</head>\n<body>\n  <div class=\"header\">\n    <div class=\"header-inner\">\n      <a href=\"https://sandbox.evernote.com/Home.action?/\" class=\"evernote-logo\"><svg xmlns=\"http://www.w3.org/2000/svg\" width=\"160\" height=\"36\" viewBox=\"0 0 160 36\">\n  <title>Evernote</title>\n  <g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(-14.89 -14.89)\">\n    <rect width=\"189.752\" height=\"65.168\" y=\".117\"/>\n    <g fill=\"#fff\" fill-rule=\"nonzero\" transform=\"translate(14.89 14.89)\">\n      <g transform=\"translate(38.54 5.84)\">\n        <path class=\"evernote-logo-2018-text\" d=\"M.233576642 19.1824818L1.22627737 18.9781022C2.10218978 18.7445255 2.33576642 18.6277372 2.33576642 16.8759124L2.33576642 3.12408759C2.33576642 1.37226277 2.0729927 1.22627737 1.22627737 1.02189781L.233576642.817518248.233576642 0 16.0583942 0 16.350365 5.81021898 15.4452555 5.81021898C14.7153285 4.20437956 14.2481752 3.35766423 13.810219 2.71532847 12.8759124 1.37226277 12.2627737 1.25547445 10.2481752 1.25547445 8.75912409 1.25547445 8.02919708 1.43065693 7.59124088 1.54744526L7.59124088 8.99270073 8.37956204 8.99270073C10.4233577 8.99270073 10.8905109 8.75912409 11.2408759 8.11678832 11.649635 7.38686131 11.8832117 6.83211679 12.1459854 5.89781022L13.0218978 5.89781022 13.0218978 13.4306569 12.1459854 13.4306569C11.8832117 12.5255474 11.649635 11.9416058 11.2408759 11.0948905 10.8905109 10.3649635 10.5109489 10.2189781 8.37956204 10.2189781L7.59124088 10.2189781 7.59124088 15.8248175C7.59124088 18.4233577 7.67883212 18.7153285 10.5109489 18.7153285 12.8467153 18.7153285 13.3138686 18.4233577 14.2773723 16.9927007 14.8029197 16.2043796 15.3576642 14.9781022 16.1167883 13.1386861L17.0510949 13.1386861 16.6423358 20 .262773723 20 .233576642 19.1824818zM19.5036496 8.23357664C18.8321168 6.59854015 18.5109489 6.18978102 17.7810219 5.95620438L17.2262774 5.7810219 17.2262774 5.02189781 25.8978102 5.02189781 25.8978102 5.7810219 25.1094891 5.98540146C24.4963504 6.16058394 24.2043796 6.45255474 24.2043796 7.15328467 24.2043796 7.5620438 24.350365 8.05839416 24.5839416 8.70072993L27.0072993 15.3576642 27.1532847 15.3576642 29.4890511 8.70072993C29.7518248 8 29.8686131 7.50364964 29.8686131 7.09489051 29.8686131 6.45255474 29.5766423 6.13138686 28.9635036 5.98540146L28.1751825 5.7810219 28.1751825 5.02189781 33.5182482 5.02189781 33.5182482 5.7810219 32.9635036 5.95620438C32.2043796 6.2189781 31.8832117 6.65693431 31.1824818 8.55474453L26.7153285 20 24.2627737 20 19.5036496 8.23357664zM32.8467153 12.4379562C32.8467153 7.41605839 36.5547445 4.64233577 40.379562 4.64233577 44.350365 4.64233577 46.8321168 6.62773723 46.919708 11.8540146L37.3722628 11.8540146C37.459854 16.5839416 39.2408759 17.8686131 42.2189781 17.8686131 44 17.8686131 45.3722628 17.3430657 46.4525547 16.7883212L46.4525547 17.7518248C45.4306569 18.8613139 43.2408759 20.379562 40.350365 20.379562 35.3284672 20.3211679 32.8467153 17.3430657 32.8467153 12.4379562zM37.3722628 10.7445255L42.3065693 10.4817518C42.3065693 7.00729927 41.8394161 5.72262774 40.1167883 5.72262774 38.6569343 5.72262774 37.4890511 7.12408759 37.3722628 10.7445255zM54.5109489 6.86131387C55.3284672 5.98540146 56.9927007 4.55474453 58.919708 4.55474453 60.1459854 4.55474453 61.1678832 5.54744526 61.1678832 6.80291971 61.1678832 8.05839416 60.1751825 9.05109489 58.919708 9.05109489 58.0145985 9.05109489 57.1970803 8.49635036 56.8759124 7.7080292 56.7007299 7.38686131 56.3211679 7.29927007 56.0583942 7.29927007 55.5328467 7.29927007 54.919708 7.67883212 54.540146 8.02919708L54.540146 17.3722628C54.540146 18.7153285 54.6569343 18.8613139 55.5328467 19.0072993L56.4963504 19.2116788 56.4963504 20 48.1751825 20 48.1751825 19.2116788 48.9343066 19.0072993C49.8978102 18.7445255 50.0145985 18.5985401 50.0145985 17.3722628L50.0145985 8.40875912C50.0145985 7.18248175 49.8686131 7.09489051 49.0510949 6.54014599L48.0875912 5.89781022 48.0875912 5.31386861 54.1605839 4.61313869 54.4817518 4.84671533 54.4233577 6.83211679 54.5109489 6.86131387M62.0437956 19.2116788L62.8029197 19.0072993C63.7664234 18.7445255 63.8832117 18.5985401 63.8832117 17.3722628L63.8832117 8.40875912C63.8832117 7.18248175 63.7372263 7.09489051 62.919708 6.54014599L61.9562044 5.89781022 61.9562044 5.31386861 68.0291971 4.61313869 68.350365 4.81751825 68.2919708 6.65693431 68.4087591 6.65693431C69.9270073 5.57664234 71.8248175 4.61313869 73.9270073 4.61313869 76.379562 4.61313869 77.6934307 5.86861314 77.6934307 8.46715328L77.6934307 17.3430657C77.6934307 18.5985401 77.810219 18.7445255 78.7445255 18.9781022L79.5036496 19.1824818 79.5036496 19.9708029 71.4744526 19.9708029 71.4744526 19.1824818 72.1751825 19.0072993C73.0510949 18.7737226 73.1386861 18.6861314 73.1386861 17.3430657L73.1386861 9.60583942C73.1386861 7.8540146 72.4963504 7.29927007 71.1532847 7.29927007 70.1313869 7.29927007 69.1094891 7.53284672 68.4671533 7.67883212L68.4671533 17.3722628C68.4671533 18.7445255 68.5547445 18.8029197 69.4306569 19.0364964L70.1313869 19.2116788 70.1313869 20 62.1021898 20 62.1021898 19.2116788 62.0437956 19.2116788zM80.0583942 12.5255474C80.0583942 7.00729927 83.9708029 4.64233577 87.8540146 4.64233577 92.0291971 4.64233577 95.6788321 7.15328467 95.6788321 12.379562 95.6788321 17.8978102 91.8248175 20.3211679 87.8540146 20.3211679 83.6788321 20.3211679 80.0583942 17.810219 80.0583942 12.5255474zM90.8321168 12.6715328C90.8321168 6.86131387 89.7226277 5.75182482 87.7372263 5.75182482 85.9270073 5.75182482 84.8467153 7.06569343 84.8467153 12.0291971 84.8467153 17.9270073 85.810219 19.2116788 87.9124088 19.2116788 89.6350365 19.2116788 90.8321168 18.189781 90.8321168 12.6715328zM98.1605839 16.350365L98.1605839 6.71532847 96.350365 6.71532847 96.350365 6.01459854C98.5985401 5.13868613 100.321168 3.47445255 101.138686 1.16788321L102.773723 1.16788321 102.773723 5.02189781 106.59854 5.02189781 106.218978 6.71532847 102.773723 6.71532847 102.773723 16.0583942C102.773723 17.4890511 103.211679 18.0729927 104.642336 18.0729927 105.343066 18.0729927 106.189781 17.9270073 106.715328 17.810219L106.715328 18.6277372C106.014599 19.270073 104.583942 20.3211679 102.160584 20.3211679 99.5620438 20.3211679 98.1605839 19.1824818 98.1605839 16.350365zM107.29927 12.4379562C107.29927 7.41605839 111.007299 4.64233577 114.832117 4.64233577 118.80292 4.64233577 121.284672 6.62773723 121.372263 11.8540146L111.854015 11.8540146C111.941606 16.5839416 113.722628 17.8686131 116.70073 17.8686131 118.481752 17.8686131 119.854015 17.3430657 120.934307 16.7883212L120.934307 17.7518248C119.912409 18.8613139 117.722628 20.379562 114.832117 20.379562 109.781022 20.3211679 107.29927 17.3430657 107.29927 12.4379562zM111.824818 10.7445255L116.759124 10.4817518C116.759124 7.00729927 116.291971 5.72262774 114.569343 5.72262774 113.109489 5.72262774 111.941606 7.12408759 111.824818 10.7445255z\"/>\n      </g>\n      <path class=\"evernote-logo-2018-elephant\" d=\"M9.51824818,8.08759124 C9.51824818,8.4379562 9.48905109,9.02189781 9.13868613,9.40145985 C8.75912409,9.75182482 8.17518248,9.7810219 7.82481752,9.7810219 L4.08759124,9.7810219 C3.00729927,9.7810219 2.3649635,9.7810219 1.9270073,9.83941606 C1.69343066,9.86861314 1.40145985,9.98540146 1.25547445,10.0437956 C1.19708029,10.0729927 1.19708029,10.0437956 1.22627737,10.0145985 L9.75182482,1.34306569 C9.7810219,1.31386861 9.81021898,1.31386861 9.7810219,1.37226277 C9.72262774,1.51824818 9.60583942,1.81021898 9.57664234,2.04379562 C9.51824818,2.48175182 9.51824818,3.12408759 9.51824818,4.20437956 L9.51824818,8.08759124 Z M17.459854,34.3065693 C16.4671533,33.6642336 15.9416058,32.8175182 15.7372263,32.2919708 C15.5328467,31.7956204 15.4160584,31.2408759 15.4160584,30.6861314 C15.4160584,28.2627737 17.4014599,26.2773723 19.8540146,26.2773723 C20.5839416,26.2773723 21.1678832,26.8613139 21.1678832,27.5912409 C21.1678832,28.0875912 20.9051095,28.4963504 20.4963504,28.729927 C20.350365,28.8175182 20.1459854,28.8759124 20,28.9051095 C19.8540146,28.9343066 19.2992701,28.9927007 19.0364964,29.2262774 C18.7445255,29.459854 18.5109489,29.8394161 18.5109489,30.2481752 C18.5109489,30.6861314 18.6861314,31.0948905 18.9781022,31.3868613 C19.5036496,31.9124088 20.2043796,32.2043796 20.9635036,32.2043796 C22.9489051,32.2043796 24.5547445,30.5985401 24.5547445,28.6131387 C24.5547445,26.8321168 23.3576642,25.2554745 21.7810219,24.5547445 C21.5474453,24.4379562 21.1678832,24.350365 20.8175182,24.2627737 C20.379562,24.1751825 19.9708029,24.1167883 19.9416058,24.1167883 C18.7153285,23.9708029 15.649635,23.0072993 15.4452555,20.2919708 C15.4452555,20.2919708 14.540146,24.379562 12.729927,25.4890511 C12.5547445,25.5766423 12.3211679,25.6642336 12.0583942,25.7226277 C11.7956204,25.7810219 11.5036496,25.810219 11.4160584,25.810219 C8.46715328,25.9854015 5.34306569,25.0510949 3.18248175,22.8321168 C3.18248175,22.8321168 1.72262774,21.6350365 0.96350365,18.2773723 C0.788321168,17.459854 0.437956204,16 0.233576642,14.6277372 C0.145985401,14.1313869 0.116788321,13.7518248 0.0875912409,13.4014599 C0.0875912409,11.9708029 0.96350365,11.0072993 2.0729927,10.8613139 C2.10218978,10.8613139 2.18978102,10.8613139 2.24817518,10.8613139 C2.91970803,10.8613139 8.02919708,10.8613139 8.02919708,10.8613139 C9.05109489,10.8613139 9.6350365,10.5985401 10.0145985,10.2481752 C10.5109489,9.7810219 10.6277372,9.10948905 10.6277372,8.32116788 C10.6277372,8.32116788 10.6277372,3.00729927 10.6277372,2.33576642 C10.6277372,2.30656934 10.6277372,2.18978102 10.6277372,2.16058394 C10.7737226,1.08029197 11.7372263,0.175182482 13.1678832,0.175182482 C13.1678832,0.175182482 13.6058394,0.175182482 13.8686131,0.175182482 C14.1605839,0.175182482 14.5109489,0.204379562 14.8321168,0.233576642 C15.0656934,0.262773723 15.270073,0.321167883 15.620438,0.408759124 C17.4014599,0.846715328 17.7810219,2.65693431 17.7810219,2.65693431 C17.7810219,2.65693431 21.1386861,3.24087591 22.8321168,3.53284672 C24.4379562,3.82481752 28.4087591,4.08759124 29.1678832,8.08759124 C30.9489051,17.6058394 29.8686131,26.8321168 29.7810219,26.8321168 C28.5255474,35.8248175 21.0510949,35.3868613 21.0510949,35.3868613 C19.4452555,35.3868613 18.2481752,34.8613139 17.459854,34.3065693 Z M24.1751825,15.1824818 C23.2116788,15.0948905 22.3941606,15.4744526 22.1021898,16.2043796 C22.0437956,16.350365 21.9854015,16.5255474 22.0145985,16.6131387 C22.0437956,16.7007299 22.1021898,16.729927 22.1605839,16.7591241 C22.5109489,16.9343066 23.0948905,17.0218978 23.9416058,17.1094891 C24.7883212,17.1970803 25.3722628,17.2554745 25.7518248,17.1970803 C25.810219,17.1970803 25.8686131,17.1678832 25.9270073,17.080292 C25.9854015,16.9927007 25.9562044,16.8175182 25.9562044,16.6715328 C25.8394161,15.8540146 25.1386861,15.2992701 24.1751825,15.1824818 Z\"/>\n    </g>\n  </g>\n</svg></a></div>\n  </div>\n  <div id=\"container-boundingbox\" class=\"wrapper\">\n    <div id=\"container\" class=\"wrapper\">\n      <div class=\"main\">\n        <div class=\"page-header\">\n          <h1>\n            Oops, we encountered an error.</h1>\n        </div>\n        <div>\n          <p>\n            Sorry, we've encountered an unexpected error.</p>\n        </div>\n        <div class=\"clear\"></div>\n      </div>\n    </div>\n    <div class=\"footer wrapper\">\n      <a href=\"https://sandbox.evernote.com/Home.action?/tos/\" class=\"footer-entry\">Terms of Service</a><a href=\"https://sandbox.evernote.com/Home.action?/privacy/\" class=\"footer-entry\">Privacy Policy</a><span class=\"footer-entry last\">Copyright 2021 Evernote Corporation. All rights reserved.</span>\n    </div>\n  </div>\n</body>\n</html>\n"} 

最终答案 原因是consumerKey不对。 申请和注册的consumerKey不一样,使用注册的consumerKey解决了401错误