403 response. The content in the registration token does not match the content in the authentication ticket
[Edited -- don't leak your tokens!]
Hi! I have written a script that saves the chat history using SkPy. There is one Skype account that raises error on this line:
sk = Skype(login, pass)
Traceback:
File "/usr/local/lib/python3.5/dist-packages/skpy/main.py", line 67, in __init__
self.conn.readToken()
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 286, in readToken
raise SkypeAuthException("No token file specified")
skpy.core.SkypeAuthException: No token file specified
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "skype_2.py", line 10, in <module>
sk = skpy.Skype(username, password)
File "/usr/local/lib/python3.5/dist-packages/skpy/main.py", line 69, in __init__
self.conn.getSkypeToken()
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 264, in getSkypeToken
self.liveLogin(user, pwd)
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 363, in liveLogin
self.getRegToken()
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 423, in getRegToken
endpoint.config()
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 866, in config
"version": "908/1.30.0.128"}})
File "/usr/local/lib/python3.5/dist-packages/skpy/conn.py", line 217, in __call__
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('403 response from PUT https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/{b817f8f9-b663-42ca-a874-81bd120c3c0f}/presenceDocs/messagingService', <Response [403]>)
I set SKPY_DEBUG_HTTP=1, and that's what I got:
...
<= [05/05 09:59:58] POST https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints
{'json': {'endpointFeatures': 'Agent'}}
{'BehaviorOverride': 'redirectAs404', 'LockAndKey': '[email protected]; time=1493967598; lockAndKeyResponse=7570fc7a3e61d7efa8ea80d87b909cd9', 'Authentication': 'skypetoken=<snip>'}
=> [05/05 09:59:59] 201
{'Cache-Control': 'no-store, must-revalidate, no-cache',
'Content-Length': '2',
'Content-Type': 'application/json; charset=utf-8',
'ContextId': 'tcid=694389951560002120,server=DB5SCH101121443',
'Date': 'Fri, 05 May 2017 07:00:04 GMT',
'Location': 'https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/%7B411eb5ac-0928-4b7c-8181-b396ba1faa70%7D',
'Pragma': 'no-cache',
'Set-RegistrationToken': 'registrationToken=<snip>; '
'expires=1494054003; '
'endpointId={411eb5ac-0928-4b7c-8181-b396ba1faa70}',
'X-Content-Type-Options': 'nosniff'}
{}
<= [05/05 09:59:59] PUT https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/{411eb5ac-0928-4b7c-8181-b396ba1faa70}/presenceDocs/messagingService
{'json': {'id': 'messagingService',
'privateInfo': {'epname': 'skype'},
'publicInfo': {'capabilities': '',
'nodeInfo': 'xx',
'skypeNameVersion': 'skype.com',
'type': 1,
'version': '908/1.30.0.128'},
'selfLink': 'uri',
'type': 'EndpointPresenceDoc'}}
{'RegistrationToken': 'registrationToken=<snip>'}
=> [05/05 09:59:59] 403
{'Cache-Control': 'no-store, must-revalidate, no-cache',
'Content-Length': '0',
'ContextId': 'tcid=7144462099043544476,server=DB5SCH101100730',
'Date': 'Fri, 05 May 2017 07:00:05 GMT',
'Pragma': 'no-cache',
'StatusText': 'The content in the registration token does not match the '
'content in the authentication ticket'}
Thanks in advance!
The content in the registration token does not match the content in the authentication ticket
Not seen that one before...
You missed most of the information requested in the issue template:
- Skype or Microsoft account?
- Is this reliably reproducible?
- Can you authenticate to Skype for Web?
Thanks for your reply!
Skype account, log in with a Skype username and password. This error can be reproduced but only for my certain account. All other accounts work fine. Yes, I can authenticate to Skype for Web.
It seems most of these auth quirks only affect a small proportion of users. 🙁
Can't reproduce here, so you'll need to try a fresh login on Skype for Web whilst watching the network requests in dev tools. Unfortunately there's a lot of cruft and noise from analytics and other non-important requests going on. If you're using Chrome, here's a filter string to cut some of it out:
-method:OPTIONS -domain:browser.pipe.aria.microsoft.com -domain:trouter.io
I suspect it'll be down to the registration token request (POST /v1/users/ME/endpoints), so take a look at that, and compare the payloads between Skype for Web and what you posted above.
The PUT /v1/users/ME/endpoints/{...}/presenceDocs/messagingService may also differ.
Well, this is what I get in Chrome:
POST /v1/users/ME/endpoints

and PUT /v1/users/ME/endpoints/{...}/presenceDocs/messagingService

Can't see any visible differences between those requests, so I'm not sure what the server dislikes. 😟
I also ran into this issue on one account (another one works just fine):
=> [15/06 17:25:54] 403
{'Cache-Control': 'no-store, must-revalidate, no-cache',
'Content-Length': '0',
'ContextId': 'tcid=SNIP,server=SNIP',
'Date': 'Thu, 15 Jun 2017 15:25:52 GMT',
'Pragma': 'no-cache',
'StatusText': 'The content in the registration token does not match the content in the authentication ticket'}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/skpy/main.py", line 69, in __init__
self.conn.getSkypeToken()
File "/usr/local/lib/python2.7/site-packages/skpy/conn.py", line 264, in getSkypeToken
self.liveLogin(user, pwd)
File "/usr/local/lib/python2.7/site-packages/skpy/conn.py", line 363, in liveLogin
self.getRegToken()
File "/usr/local/lib/python2.7/site-packages/skpy/conn.py", line 423, in getRegToken
endpoint.config()
File "/usr/local/lib/python2.7/site-packages/skpy/conn.py", line 866, in config
"version": "908/1.30.0.128"}})
File "/usr/local/lib/python2.7/site-packages/skpy/conn.py", line 217, in __call__
raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
skpy.core.SkypeApiException: ('403 response from PUT https://db5-client-s.gateway.messenger.live.com/v1/users/ME/endpoints/{SNIP}/presenceDocs/messagingService', <Response [403]>)
Same problem.
- Microsoft account? - YES
- Is this reliably reproducible? - YES
- Can you authenticate to Skype for Web? - YES
I create new skype account (today): "[email protected]", "XXmARWFX35E7"
Windows Server 2012 python 2.7
pip install skpy (yesterday)
Test script:
====================
skpy_test.py
====================
# -*- coding: utf-8 -*-
import os
os.environ['SKPY_DEBUG_HTTP'] = "1"
# Отключаем варнинги InsecurePlatformWarning в консоль
import requests.packages.urllib3
requests.packages.urllib3.disable_warnings()
# Строки ниже включают логирование в requests.
# Источник - http://stackoverflow.com/a/16630836
# These two lines enable debugging at httplib level (requests->urllib3->http.client)
# You will see the REQUEST, including HEADERS and DATA, and RESPONSE with HEADERS but without DATA.
# The only thing missing will be the response.body which is not logged.
try:
import http.client as http_client
except ImportError:
# Python 2
import httplib as http_client
http_client.HTTPConnection.debuglevel = 1
# You must initialize logging, otherwise you'll not see debug output.
import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("requests.packages.urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True
import requests
old_meth = requests.Session.request
def new_meth(*args, **kwargs):
kwargs['verify'] = False
# print 1231231, args, kwargs
# raise RuntimeError(123)
return old_meth(*args, **kwargs)
requests.Session.request = new_meth
# import skpy_hacked
import skpy
s = skpy.Skype("[email protected]", "XXmARWFX35E7")
print s
====================
Run it:
python skpy_test.py
My output:
The content in the registration token does not match the content in the authentication ticket
skpy.core.SkypeApiException: ('403 response from POST https://client-s.gateway.messenger.live.com/v1/users/ME/endpoints', <Response [403]>)
Sceenshot:

I done this for solving this problem:
pip uninstall skpy
Then:
install "skpy" from sources - branch "master": https://github.com/OllieTerrance/SkPy/archive/master.zip
Result:
OK

To confirm, the version on Github works but not the one published on pip?
Latest release == git master, there shouldn't be any difference. More likely a timing/temporary issue?
@pvoytko Could you check if the version installed from pip was the latest one (0.8.1) or an older one?
@demurgos
Could you check if the version installed from pip was the latest one (0.8.1) or an older one?
Sorry, i am mistake
Same code:
Load from PIP: pip install --trusted-host pypi.python.org skpy Screenshot http://pvoytko.ru/jx/i2x7RFQQ0X Successfully installed skpy-0.8.1
Load from sources: https://github.com/OllieTerrance/SkPy/archive/master.zip Screenshot http://pvoytko.ru/jx/11wta3YBXb
Compare code - i see same code: diff folders http://pvoytko.ru/jx/amsPfCgYKp - one file diff file http://pvoytko.ru/jx/U1VVHxOiwo - diff in comment
More likely a timing/temporary issue?
@OllieTerrance
may be reason is

I am facing this issue.., is there any mordern library exists today??