ocilo / skype-http

Unofficial Skype API for Node.js via HTTP
https://ocilo.github.io/skype-http
MIT License
51 stars 24 forks source link

Handling when "Javascript is required" to login #40

Closed kfatehi closed 7 years ago

kfatehi commented 7 years ago

Hi there.

Nice library! I like how verbose this error is -- it's very clear what the problem is. My question is whether or not dealing with this scenario is in scope of skype-http -- I'm assuming it is not:

For context, this is happening when logging in on a machine which has not logged into skype before through a normal client (i.e. I am guessing we are running into a security measure when Microsoft notices a login from a strange IP such as a virtual private server).

MicrosoftAccountLogin: Unable to login with MicrosoftAccount.
  caused by GetLiveToken: Unable to get the Live token for Skype
  caused by LiveTokenNotFound: Unable to find the Live token. This token is normally found in the HTML response as the value of the element with the id "t". This error may be caused by a change in the Microsoft login workflow. HTML page: "<html><head><noscript>JavaScript required to sign in<meta http-equiv=\"Refresh\" content=\"0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033\"/></noscript><title>Continue</title><script type=\"text/javascript\">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload=\"javascript:DoSubmit();\"><form name=\"fmHF\" id=\"fmHF\" action=\"https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d20B63404CFB06BE2&mkt=EN-US&uiflavor=web&id=293290&uaid=ef101e26ba7ac7723c7241ecaca40cb1\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"ipt\" id=\"ipt\" value=\"Dfk7QGQf8!GGva9nb6r*2iXDtuYzpFtbqyInAWOdXUL*6GEcPBL!yWlm4koF!w1BByhraPWpkN7HdGaZ5nFvaugs7g5AxtaZD95BUmvmVyec9GqyRQcFJsP2POnu!avtdMFUwHRF54CdPc3yyqQMAcj6hQE*pTG2Pzxbql2W9emzQzTjE2k0i6RtyC1SNkH3e4bpWvCyTb0*ZV4Yov69k3Jm9CqJblo8pN3TdarmZoKwD8Bo0xgnujcEVcdqQjqX50gDUtq6P1udIjmYUv!WUZAUtNeluy*Yj7z!BIu8CZnoQjqOizc5WOyOl5MQMSn4KsdFiPye5XzJDSsK5iNUgz4aNmrPhPgC6OWohhYpOG!SkLRAHd1mMvDf*TxBhc2eHJDTVs6eK!rwjVbByXwbw0U6QMpnmvN84PEifvfqKfRn0pKSWYfkC1Md0hDPo8xTFHDQARpLXvl93AHCs1A3dII$\"></form></body></html>"
    at Object.create (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/errors/microsoft-account/get-live-token.js:17:16)
    at scrapLiveToken (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:221:61)
    at /home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:138:20
    at Generator.next (<anonymous>)
    at fulfilled (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:4:58)
    at process._tickCallback (internal/process/next_tick.js:109:7)
  name: 'MicrosoftAccountLogin',
  data: {},
  cause:
   { GetLiveToken: Unable to get the Live token for Skype
     caused by LiveTokenNotFound: Unable to find the Live token. This token is normally found in the HTML response as the value of the element with the id "t". This error may be caused by a change in theMicrosoft login workflow. HTML page: "<html><head><noscript>JavaScript required to sign in<meta http-equiv=\"Refresh\" content=\"0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033\"/></noscript><title>Continue</title><script type=\"text/javascript\">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload=\"javascript:DoSubmit();\"><form name=\"fmHF\" id=\"fmHF\" action=\"https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d20B63404CFB06BE2&mkt=EN-US&uiflavor=web&id=293290&uaid=ef101e26ba7ac7723c7241ecaca40cb1\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"ipt\" id=\"ipt\" value=\"Dfk7QGQf8!GGva9nb6r*2iXDtuYzpFtbqyInAWOdXUL*6GEcPBL!yWlm4koF!w1BByhraPWpkN7HdGaZ5nFvaugs7g5AxtaZD95BUmvmVyec9GqyRQcFJsP2POnu!avtdMFUwHRF54CdPc3yyqQMAcj6hQE*pTG2Pzxbql2W9emzQzTjE2k0i6RtyC1SNkH3e4bpWvCyTb0*ZV4Yov69k3Jm9CqJblo8pN3TdarmZoKwD8Bo0xgnujcEVcdqQjqX50gDUtq6P1udIjmYUv!WUZAUtNeluy*Yj7z!BIu8CZnoQjqOizc5WOyOl5MQMSn4KsdFiPye5XzJDSsK5iNUgz4aNmrPhPgC6OWohhYpOG!SkLRAHd1mMvDf*TxBhc2eHJDTVs6eK!rwjVbByXwbw0U6QMpnmvN84PEifvfqKfRn0pKSWYfkC1Md0hDPo8xTFHDQARpLXvl93AHCs1A3dII$\"></form></body></html>"
       at Object.create (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/errors/microsoft-account/get-live-token.js:17:16)
       at scrapLiveToken (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:221:61)
       at /home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:138:20
       at Generator.next (<anonymous>)
       at fulfilled (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:4:58)
       at process._tickCallback (internal/process/next_tick.js:109:7)
     name: 'GetLiveToken',
     data: {},
     cause:
      { LiveTokenNotFound: Unable to find the Live token. This token is normally found in the HTML response as the value of the element with the id "t". This error may be caused by a change in the Microsoft login workflow. HTML page: "<html><head><noscript>JavaScript required to sign in<meta http-equiv=\"Refresh\" content=\"0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033\"/></noscript><title>Continue</title><script type=\"text/javascript\">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload=\"javascript:DoSubmit();\"><form name=\"fmHF\" id=\"fmHF\" action=\"https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d20B63404CFB06BE2&mkt=EN-US&uiflavor=web&id=293290&uaid=ef101e26ba7ac7723c7241ecaca40cb1\" method=\"post\" target=\"_top\"><input type=\"hidden\" name=\"ipt\" id=\"ipt\" value=\"Dfk7QGQf8!GGva9nb6r*2iXDtuYzpFtbqyInAWOdXUL*6GEcPBL!yWlm4koF!w1BByhraPWpkN7HdGaZ5nFvaugs7g5AxtaZD95BUmvmVyec9GqyRQcFJsP2POnu!avtdMFUwHRF54CdPc3yyqQMAcj6hQE*pTG2Pzxbql2W9emzQzTjE2k0i6RtyC1SNkH3e4bpWvCyTb0*ZV4Yov69k3Jm9CqJblo8pN3TdarmZoKwD8Bo0xgnujcEVcdqQjqX50gDUtq6P1udIjmYUv!WUZAUtNeluy*Yj7z!BIu8CZnoQjqOizc5WOyOl5MQMSn4KsdFiPye5XzJDSsK5iNUgz4aNmrPhPgC6OWohhYpOG!SkLRAHd1mMvDf*TxBhc2eHJDTVs6eK!rwjVbByXwbw0U6QMpnmvN84PEifvfqKfRn0pKSWYfkC1Md0hDPo8xTFHDQARpLXvl93AHCs1A3dII$\"></form></body></html>"
          at Object.create (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/errors/microsoft-account/get-live-token.js:17:16)
          at scrapLiveToken (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:221:61)
          at /home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:138:20
          at Generator.next (<anonymous>)
          at fulfilled (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:4:58)
          at process._tickCallback (internal/process/next_tick.js:109:7)
        name: 'LiveTokenNotFound',
        data: [Object],
        message: 'LiveTokenNotFound: Unable to find the Live token. This token is normally found in the HTML response as the value of the element with the id "t". This error may be caused by a change in the Microsoft login workflow. HTML page: "<html><head><noscript>JavaScript required to sign in<meta http-equiv=\\"Refresh\\" content=\\"0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033\\"/></noscript><title>Continue</title><script type=\\"text/javascript\\">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload=\\"javascript:DoSubmit();\\"><form name=\\"fmHF\\" id=\\"fmHF\\" action=\\"https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d20B63404CFB06BE2&mkt=EN-US&uiflavor=web&id=293290&uaid=ef101e26ba7ac7723c7241ecaca40cb1\\" method=\\"post\\" target=\\"_top\\"><input type=\\"hidden\\" name=\\"ipt\\" id=\\"ipt\\" value=\\"Dfk7QGQf8!GGva9nb6r*2iXDtuYzpFtbqyInAWOdXUL*6GEcPBL!yWlm4koF!w1BByhraPWpkN7HdGaZ5nFvaugs7g5AxtaZD95BUmvmVyec9GqyRQcFJsP2POnu!avtdMFUwHRF54CdPc3yyqQMAcj6hQE*pTG2Pzxbql2W9emzQzTjE2k0i6RtyC1SNkH3e4bpWvCyTb0*ZV4Yov69k3Jm9CqJblo8pN3TdarmZoKwD8Bo0xgnujcEVcdqQjqX50gDUtq6P1udIjmYUv!WUZAUtNeluy*Yj7z!BIu8CZnoQjqOizc5WOyOl5MQMSn4KsdFiPye5XzJDSsK5iNUgz4aNmrPhPgC6OWohhYpOG!SkLRAHd1mMvDf*TxBhc2eHJDTVs6eK!rwjVbByXwbw0U6QMpnmvN84PEifvfqKfRn0pKSWYfkC1Md0hDPo8xTFHDQARpLXvl93AHCs1A3dII$\\"></form></body></html>"\n    at Object.create (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/errors/microsoft-account/get-live-token.js:17:16)\n    at scrapLiveToken (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:221:61)\n    at /home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:138:20\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:4:58)\n    at process._tickCallback (internal/process/next_tick.js:109:7)' },
     message: 'GetLiveToken: Unable to get the Live token for Skype\n  caused by LiveTokenNotFound: Unable to find the Live token. This token is normally found in the HTML response as the value of the element with the id "t". This error may be caused by a change in the Microsoft login workflow. HTML page: "<html><head><noscript>JavaScript required to sign in<meta http-equiv=\\"Refresh\\" content=\\"0; URL=https://login.live.com/jsDisabled.srf?mkt=EN-US&lc=1033\\"/></noscript><title>Continue</title><script type=\\"text/javascript\\">function OnBack(){}function OnNext(){}function DoSubmit(){var subt=false;if(!subt){subt=true;document.fmHF.submit();}}</script></head><body onload=\\"javascript:DoSubmit();\\"><form name=\\"fmHF\\" id=\\"fmHF\\" action=\\"https://account.live.com/identity/confirm?ru=https://login.live.com/login.srf%3flc%3d1033%26sf%3d1%26id%3d293290%26tw%3d18000%26fs%3d0%26ts%3d-1%26sec%3d%26mspp_shared%3d1%26seclog%3d10%26claims%3d%26wa%3dwsignin1.0%26wp%3dMBI_SSL%26ru%3dhttps://lw.skype.com/login/oauth/proxy%253fclient_id%253d578134%2526site_name%253dlw.skype.com%2526redirect_uri%253dhttps%25253A%25252F%25252Fweb.skype.com%25252F%26contextid%3d20B63404CFB06BE2&mkt=EN-US&uiflavor=web&id=293290&uaid=ef101e26ba7ac7723c7241ecaca40cb1\\" method=\\"post\\" target=\\"_top\\"><input type=\\"hidden\\" name=\\"ipt\\" id=\\"ipt\\" value=\\"Dfk7QGQf8!GGva9nb6r*2iXDtuYzpFtbqyInAWOdXUL*6GEcPBL!yWlm4koF!w1BByhraPWpkN7HdGaZ5nFvaugs7g5AxtaZD95BUmvmVyec9GqyRQcFJsP2POnu!avtdMFUwHRF54CdPc3yyqQMAcj6hQE*pTG2Pzxbql2W9emzQzTjE2k0i6RtyC1SNkH3e4bpWvCyTb0*ZV4Yov69k3Jm9CqJblo8pN3TdarmZoKwD8Bo0xgnujcEVcdqQjqX50gDUtq6P1udIjmYUv!WUZAUtNeluy*Yj7z!BIu8CZnoQjqOizc5WOyOl5MQMSn4KsdFiPye5XzJDSsK5iNUgz4aNmrPhPgC6OWohhYpOG!SkLRAHd1mMvDf*TxBhc2eHJDTVs6eK!rwjVbByXwbw0U6QMpnmvN84PEifvfqKfRn0pKSWYfkC1Md0hDPo8xTFHDQARpLXvl93AHCs1A3dII$\\"></form></body></html>"\n    at Object.create (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/errors/microsoft-account/get-live-token.js:17:16)\n    at scrapLiveToken (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:221:61)\n    at /home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:138:20\n    at Generator.next (<anonymous>)\n    at fulfilled (/home/keyvan/code/matrix-puppet-skype/node_modules/skype-http/dist/lib-es2015/lib/providers/microsoft-account.js:4:58)\n    at process._tickCallback (internal/process/next_tick.js:109:7)' } }
mitchcapper commented 7 years ago

If you login via skype web (https://web.skype.com) do you get any prompts? Does it work after logging in on there from the same pc?

kfatehi commented 7 years ago

This is on a VPS, so I need to find a reliable way to appear as though I'm there.

mitchcapper commented 7 years ago

@kfatehi it looks like an identity confirm prompt looking at the links. You need to setup a proxy or similar on the vps and login to skype web to do the identity confirm and then it should work. Please reply back if this fails.

demurgos commented 7 years ago

I am glad that the error was clear. I'd like all the errors to be this good but it's pretty long...

I am not sure if we can do much at this point, but it could be useful to recognize some "known" failure scenarios to provide a more specific error. Currently we recognize wrong credentials and rate limits but there are other common errors such as captchas that could benefit from a better error. Ideally, you should be able to switch on the error name to then provide the appropriate way to deal with the login error to your users.