Terrance/SkPy

Login fails with skpy 0.10.2

Closed this issue · 2 comments

I have an old, pre-Microsoft Skype account, which should be linked to a Microsoft account.

Running:

from skpy import Skype
sk = Skype(myusername, mypassword)

yields:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\skpy\main.py", line 69, in __init__
    self.conn.getSkypeToken()
  File "C:\Python\lib\site-packages\skpy\conn.py", line 188, in inner
    return method(*args, **kwargs)
  File "C:\Python\lib\site-packages\skpy\conn.py", line 395, in liveLogin
    self.tokens["skype"], self.tokenExpiry["skype"] = SkypeLiveAuthProvider(self).auth(user, pwd)
  File "C:\Python\lib\site-packages\skpy\conn.py", line 599, in auth
    params["opid"] = self.sendCreds(user, pwd, params)
  File "C:\Python\lib\site-packages\skpy\conn.py", line 641, in sendCreds
    raise SkypeApiException("Couldn't retrieve opid field from login response", loginResp)
SkypeApiException: ("Couldn't retrieve opid field from login response", <Response [200]>)

and sometimes:

Traceback (most recent call last):
  File "C:\Python\lib\site-packages\skpy\main.py", line 69, in __init__
    self.conn.getSkypeToken()
  File "C:\Python\lib\site-packages\skpy\conn.py", line 188, in inner
    return method(*args, **kwargs)
  File "C:\Python\lib\site-packages\skpy\conn.py", line 395, in liveLogin
    self.tokens["skype"], self.tokenExpiry["skype"] = SkypeLiveAuthProvider(self).auth(user, pwd)
  File "C:\Python\lib\site-packages\skpy\conn.py", line 595, in auth
    params = self.getParams()
  File "C:\Python\lib\site-packages\skpy\conn.py", line 614, in getParams
    raise SkypeApiException("Couldn't retrieve PPFT from login form", loginResp)
SkypeApiException: ("Couldn't retrieve PPFT from login form", <Response [200]>)

Login works fine with skpy 0.10.1. As does logging in at live.com with a browser.

Setting SKPY_DEBUG_HTTP=1 yields pages of data, hopefully this is the most relevant:

<= [13/01 16:27:29] GET https://login.skype.com/login/oauth/microsoft
{'params': {'client_id': '578134', 'redirect_uri': 'https://web.skype.com'}}
=> [13/01 16:27:30] 200
{'Cache-Control': 'no-store, max-age=0',
 'Content-Encoding': 'gzip',
 'Content-Length': '10244',
 'Content-Type': 'text/html; charset=utf-8',
 'Date': 'Wed, 13 Jan 2021 14:27:32 GMT',
 'Expires': 'Wed, 13 Jan 2021 14:26:33 GMT',
 'P3P': 'CP="DSP CUR OTPi IND OTRi ONL FIN"',
 'PPServer': 'PPV: 30 H: BY1PPF53E8ED147 V: 0',
 'Referrer-Policy': 'strict-origin-when-cross-origin',
 'Set-Cookie': 'uaid=1257b030bdf24787a57804205f9d30f5; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly, cltm=cf:ReservedFlight33$2cReservedFligh; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly, MSPRequ=id=293290&lt=1610548053&co=1; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly, MSCC=82.131.86.104-EE; expires=Mon, 07-Feb-2022 14:27:33 GMT; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly, OParams=11DQdvw5wH3oY8TcuG8VAdD1pyr9YW3NIWo12UDJdFjiGI9Zl1U2HBT9AyvnNTzw68pfmO1pHa8f*8FhDbcXeomc63LgPhhpnscHhN2QIABK2dpRCn1yY25wurJRg5ETf0363PULrRss52MaV7kQngwMv*beRH19YgMgTrWkMX6PDpg*qdHyaXVo6V5e2G5bQ9lc2fUQ9pglWmVSqQj2TfgweJAGIN!1aUYqxoQhQW3NZ2ubNBABwgYA1IoYBPrRFElLEZStuipVTBvgUwMRviZUIDw0GBVjuCfwk7O1ThV6JwZVhcUZ9NrXcq*yWKoikPqg*CRqYdVvAWW0nRLZ9HIZZM38Fx2Sa0SjtpBqE*bIXyKaEW6YQQQ10foONKdDnk3PyjmOJwd7ZrDrQm1VGh!XwG2JWnL8wnsOi5zOBfyHuAcd7gZAf*v7SaInClJgNjsS7pdweO46sflsF1eL1dtIf0d7ASYFYRCkleJxqyz8zuzLopzLfVhGUECpQZVgm2yOkVsHISm2ja*qNlKRJccYdpa!gk0I3ub9kf7kvdwVXbg6eocWjjG4ZQldj*bSabmGj**071iJ4mwQsjXG0csGjivQDt2mEiodYF7izW3jBE; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly, MSPOK=$uuid-c9986963-9a5a-4912-8801-8ff944a420cf; domain=login.live.com; Secure; path=/; SameSite=None; HttpOnly',
 'Strict-Transport-Security': 'max-age=31536000',
 'Vary': 'Accept-Encoding',
 'X-Content-Type-Options': 'nosniff',
 'X-Frame-Options': 'deny',
 'X-XSS-Protection': '1; mode=block',
 'x-ms-request-id': 'd909b926-86f4-42fc-b85d-41d0c0f3d9b1'}

/../

<= [13/01 16:27:30] POST https://login.live.com/ppsecure/post.srf
{'cookies': {'CkTst': 'G1610548050948',
             'MSPOK': '$uuid-c9986963-9a5a-4912-8801-8ff944a420cf',
             'MSPRequ': 'id=293290&lt=1610548053&co=1'},
 'data': {'PPFT': u'DbDY7Hm8*4xWVgC2IBwnG3wo1h1qGX9170tfKVgXSfaH9Hh2WF7kA64!RdXR55acaIoAus36rxzQwe4yrwJ8nBvZ1l0QFmthm2VAzBza9*nDYvN95yw*xP8S34w!7ezUynBzam1EsHdT0TGT0N*ZYZb48HJ0EKMTD!Y7bdNpw5l1Vs0BkAZHU2QjNmX0GK1s2EEM!Ehi7JNJpTOygyszsMf*Gh!0NUGUTjowGX7ft4sAN76fcgjXWAuyyY1IlTUwIw*j6C*AgWufD4D*7FGLTvE$',
          'login': 'myusername',
          'loginoptions': '3',
          'passwd': 'mypassword'},
 'params': {'wa': 'wsignin1.0',
            'wp': 'MBI_SSL',
            'wreply': 'https://lw.skype.com/login/oauth/proxy?client_id=578134&site_name=lw.skype.com&redirect_uri=https%3A%2F%2Fweb.skype.com%2F'}}
=> [13/01 16:27:31] 200
{'Content-Encoding': 'gzip',
 'Content-Length': '3801',
 'Content-Type': 'text/html; charset=utf-8',
 'Date': 'Wed, 13 Jan 2021 14:27:33 GMT',
 'PPServer': 'PPV: 30 H: SJ1PPF97E72EFF3 V: 0',
 'Referrer-Policy': 'strict-origin-when-cross-origin',
 'Strict-Transport-Security': 'max-age=31536000',
 'Vary': 'Accept-Encoding',
 'X-Content-Type-Options': 'nosniff',
 'X-XSS-Protection': '1; mode=block',
 'x-ms-request-id': '86135043-fcd1-4c1a-a354-2dc6edd8dbd3'}
<!-- ServerInfo: SJ1PPF97E72EFF3 2021.01.08.00.05.12 Live1 Unknown LocVer:0 --><!-- PreprocessInfo: azbldrun:AzBuildCU-Ha02, 2021-01-07T23:53:46.6990514-08:00 - Version: 16,0,28893,3 -->
<!-------Error Info------------------------------------------
"/pp1600/ppsecure/post.srf?wreply=https%3A%2F%2Flw.skype.com%2Flogin%2Foauth%2Fproxy%3Fclient_id%3D578134%26site_name%3Dlw.skype.com%26redirect_uri%3Dhttps%253A%252F%252Fweb.skype.com%252F&wa=wsignin1.0&wp=MBI_SSL"
loginflow(2563)
HR=0x80041F0D
Method string:GET
URL:"/pp1600/ppsecure/post.srf"
Query string:"code=1"
Server protocol:HTTP/1.1

/../

The change in 0.10.2 was to select legacy authentication when you provide a Skype username to login with -- if you're using a Microsoft-linked account, you should use the associated email address as your username instead of the Skype username for SOAP login, or choose the authentication mechanism you need manually.

Aha, I see. Indeed, using SkypeConnection.soapLogin() completes successfully.

Closing the issue, as this is sufficient for my purposes. But maybe at some point skpy could also encapsulate detecting this error on liveLogin() and trying soapLogin() instead automatically?

In any case, thank you for your great work on this library, it is really useful, with excellent interface and documentation. I can only imagine how frustrating it has been to reverse-engineer an unpublished API that the company tends to change willy-nilly.