-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-auth fails after Token became invalid (Using Skype-credentials) #45
Comments
When you provide a username/password, the I'm not sure what's going on here though. You're getting spun in a loop because this check is failing -- perhaps you could try fetching a registration token manually, and comparing the previous token and expiry to what the API gives you? prov = SkypeRegistrationTokenProvider(sk.conn)
token, expiry, msgsHost, endpoint = prov.auth(sk.conn.tokens["skype"]) |
The thing is that the LiveLogin (the replaced stub) is called in the end and subsequently fails. |
Oh, I get it´; It thinks, the token is still valid which is why verifyToken passes in getRegToken and it proceeds to call config. This is what the error looks like on later occasions:
|
There are two types of tokens -- Skype token, and registration token. The latter requires a former as part of the request, and both have their own expiries. Different APIs require different tokens. The presence and messaging endpoints (
As noted above, probably down to rate limiting. If you try to sign in to Skype for Web from the same device, you may end up at a captcha/two-factor page. If you set Please also try the snippet and comparison as suggested previously. |
@DerGenaue Any updates? (P.S. I've pushed an update that includes headers in the HTTP debug output, please pull before testing.) |
Not yet, had a stressful week but I think I can test it today |
Result of resfreshSkypeToken:
And with a fresh Skype login (direct after Password input) this is the result of getSkypeToken():
|
does this help you? |
First one renders as the username-only login form, but with no useful hidden tokens as far as I can tell. I guess that means the refresh token is invalid. There's an admittedly rather hidden disclaimer on the refresh token provider, which ought to be copied to the
That is, Microsoft account logins (email or phone number as username) aren't supported by the upstream API. Does that apply to you? Failing that, if you're trying to refresh after the Skype token expires, maybe that's too late and the refresh token expires then too... can you refresh at all before the expiry? Second one, it's looking for a |
No Microsoft login, I read that disclaimer; How did you find out about how to implement the RefreshTokenProvider? I did that refresh up there a few min after logging in |
Just tested myself, the token renewal appears to work regardless of age.
Found a mention of the endpoint over here -- haven't seen it used anywhere in Skype for Web though. |
So the refreshToken function works just fine for you? |
Yep, Skype username auth here, all seems to work. Reproducing bugs here is a right pain, things just seem to be broken for a minority of people. 🙁 |
@OllieTerrance I've also been getting some errors sometimes around refreshing the token/login. What's the recommended workflow for keeping a session active over days? |
You can use There's also a handler to get a new registration tokens on API call failure, maybe this needs extending to refresh or get Skype tokens too... |
@OllieTerrance thanks, but I'm still a bit confused from all the possible method combinations :) |
Yes, though you'd need to track the time to do that (background thread or checking |
got it. I'll try a few things out. |
so far no matter what I'm trying the account seems to get blocked when trying to relogin after 24hrs (token expiry). If I find anything else I'll update. |
Blocked how? I've toyed with my test accounts, seems like I can reauthenticate via refreshing a Skype token (if a Skype username rather than Microsoft account), or getting a new one, both before and after expiry... |
Blocked meaning - trying to |
It's possible that deleting an existing token file prior to expiration (say after 22hrs), and then creating a new Skype(user, pwd, tokenFile) succeeds in keeping that user logged in without getting blocked. |
Curious. If you're doing multiple searches, I wonder if they're flagging you for it... I'm (somewhat, at the moment) around on Hangouts or via email ( |
Could very well be flagged on multiple searches. We'll see how it goes in the upcoming days. Thanks for the chat options, I may reach out if I get some more details. Also for the code and all the help here. |
This issue has been hanging around a bit, but I haven't got a clear solution. The current implementation will request a new Skype token (via |
This may be an unrelated issue, but SkypeEventLoop throws an exception after 24 hours. Could a check be added to refresh the auth token before it expires for users of that class? |
Traceback? As long as you've provided a password at startup, it should just retry the login when the token expires. If you're using a Skype-only acccount, you can alternatively call |
Sure; this has some references to calling code.
Exception in thread Thread-1:
Traceback (most recent call last):
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
raise SocketError(str(e))
OSError: (104, 'ECONNRESET')
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/codeofdusk/.local/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/util/retry.py", line 357, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 387, in _make_request
six.raise_from(e, None)
File "<string>", line 2, in raise_from
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/connectionpool.py", line 383, in _make_request
httplib_response = conn.getresponse()
File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
response.begin()
File "/usr/lib/python3.6/http/client.py", line 297, in begin
version, status, reason = self._read_status()
File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/lib/python3.6/socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/urllib3/contrib/pyopenssl.py", line 285, in recv_into
raise SocketError(str(e))
urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "drivers/skype.py", line 109, in run
return self.loop()
File "/usr/local/lib/python3.6/dist-packages/SkPy-0.0.0-py3.6.egg/skpy/main.py", line 207, in loop
self.cycle()
File "/usr/local/lib/python3.6/dist-packages/SkPy-0.0.0-py3.6.egg/skpy/main.py", line 196, in cycle
self.onEvent(event)
File "drivers/skype.py", line 84, in onEvent
request(q, driver=self, event=event)
File "/home/codeofdusk/amanda/request.py", line 63, in __init__
self.finalize()
File "/home/codeofdusk/amanda/request.py", line 85, in finalize
self.driver.say(str(self), request=self)
File "drivers/skype.py", line 94, in say
request.kwargs['event'].msg.chat.sendMsg(msg)
File "/usr/local/lib/python3.6/dist-packages/SkPy-0.0.0-py3.6.egg/skpy/chat.py", line 142, in sendMsg
imdisplayname="{0}".format(self.skype.user.name), **kwargs)
File "/usr/local/lib/python3.6/dist-packages/SkPy-0.0.0-py3.6.egg/skpy/chat.py", line 81, in sendRaw
auth=SkypeConnection.Auth.RegToken, json=msg).json().get("OriginalArrivalTime")
File "/usr/local/lib/python3.6/dist-packages/SkPy-0.0.0-py3.6.egg/skpy/conn.py", line 208, in __call__
resp = self.sess.request(method, url, headers=headers, **kwargs)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/home/codeofdusk/.local/lib/python3.6/site-packages/requests/adapters.py", line 490, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')",))
… On 23 Jun 2018, at 14:41, Terrance ***@***.***> wrote:
Traceback?
As long as you've provided a password at startup, it should just retry the login when the token expires. If you're using a Skype-only acccount, you can alternatively call SkypeConnection.refresh() <https://skpy.t.allofti.me/internal.html#skpy.conn.SkypeConnection.refreshSkypeToken> periodically, though I'm unsure if this still works following the switch to use the Live auth flow for Skype accounts.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#45 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACXISxHo9CRWT6SvH_zhzlKKXTbl5VAJks5t_lOjgaJpZM4MH8DO>.
|
Presumably not token related (unless it happens immediately after the token expires?) -- looks like the connection is being interrupted somewhere higher up.
Whilst some generic retry logic would be possible, I'd argue it's unsafe for any API methods with side-effects, such as in your case where you're sending a message (depending on when the connection was interrupted, it may or may not have gone through). For now, you'll need to add your own handling of connection errors and decide for each case whether a retry is sensible or not. Hopefully such connection errors are rare. |
For some reason, it’s starting to happen every few minutes for me now. Used to be some sort of error about every 24 hours, but I didn’t capture the traceback.
Bill
… On 23 Jun 2018, at 16:39, Terrance ***@***.***> wrote:
Presumably not token related (unless it happens immediately after the token expires?) -- looks like the connection is being interrupted somewhere higher up.
https://github.com/OllieTerrance/SkPy/blob/70a95e6866bfabdfdd4b739bab42f8e927e3f6af/skpy/main.py#L191-L198 <https://github.com/OllieTerrance/SkPy/blob/70a95e6866bfabdfdd4b739bab42f8e927e3f6af/skpy/main.py#L191-L198>
SkypeEventLoop already handles connection errors during the initial retrieval of events, though applying it to onEvent() call is a bit too wide in scope -- e.g. if you make further external requests, any connection errors will effectively abort the handler.
Whilst some generic retry logic would be possible, I'd argue it's unsafe for any API methods with side-effects, such as in your case where you're sending a message (depending on when the connection was interrupted, it may or may not have gone through). For now, you'll need to add your own handling of connection errors and decide for each case whether a retry is sensible or not. Hopefully such connection errors are rare.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#45 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ACXIS3IlAiJZGR1nzsw2uBseGHupQ3xyks5t_m9SgaJpZM4MH8DO>.
|
Interesting... |
Why do not work Skype( username, password ) on heroku server? Token error is occured. |
After 1 day the reauth after the token became invalid failed.
The credentials should still be present as it wasn't restarted
subsequential calls failed with the same Error although not as many verifyToken-Recursions
The text was updated successfully, but these errors were encountered: