OpenXbox / xbox-smartglass-core-python

SmartGlass Core protocol python library
https://pypi.python.org/pypi/xbox-smartglass-core
MIT License
72 stars 14 forks source link

Cant refresh tokens #33

Closed whatdaybob closed 3 years ago

whatdaybob commented 4 years ago

I have a strange issue that I cant seem to see anyone else having.

I always get the error AuthenticationManager was not able to authenticate with provided tokens or user credentials! even though the refresh token is in date?

As soon as the access_token expires the home assistant plugin starts chucking out [custom_components.xboxone.media_player] Refreshing authentication tokens failed! almost every 8 seconds. I have manually tried refreshing and its still does the original error.

I am currently running this in docker using the below versions:

"xbox-smartglass-core": "1.2.2",
"xbox-smartglass-nano": null,
"xbox-webapi": "1.1.8"

I have experienced this in all versions since before it was rolled into the core. I have ran out of ideas on how to fix it, any help would be appreciated.

tuxuser commented 4 years ago

I have a strange issue that I cant seem to see anyone else having.

Seems like it, yes.

Do you have a debug log that allows to investigate it further.

whatdaybob commented 4 years ago

I am so sorry, i feel stupid. I cant seem to get it into debug mode.

I am running xbox-rest-server --logfile /home/docker/logs/xbox-rest-server -vv -b 0.0.0.0 -p 5522

It appears to not indicate any debug logging happening, console logs look normal and no log file is created.

I must be misinterpreting your simple log args somehow or I have made an error I am not able to see.

whatdaybob commented 4 years ago

I am not 100% sure but it may be because I have enabled an Identity verification application. When looking on my Microsoft account I can see the following details surrounding my original token request.

Device/platform

Unknown

Browser/application

Unknown

IP address

xx.xxx.xxx.xxx

Session activity

Successful sign-in Additional verification requested

dondch commented 4 years ago

I have same issue. home assistant logs gets flooded with:

(MainThread) [custom_components.xboxone.media_player] Refreshing authentication tokens failed!
ERROR (SyncWorker_2) [custom_components.xboxone.media_player] Refreshing authentication tokens failed!
(SyncWorker_9) [custom_components.xboxone.media_player] Failed to connect to FD0XXXXXXXXX

it helps when I re-authenticate via http://hassio.local:5557/auth/oauth

whatdaybob commented 4 years ago

Was anyone able to get any debug logging on this,

codehunter13 commented 4 years ago

i got the same errors . I run it in docker if that matters.

127.0.0.1 - - [2020-09-16 18:05:07] "GET /auth/refresh HTTP/1.1" 500 251 0.002451 127.0.0.1 - - [2020-09-16 18:05:07] "GET /auth HTTP/1.1" 200 252 0.001541 [2020-09-16 18:05:07,532] WARNING: Token Auth failed: No valid RefreshToken. Attempting auth via credentials [2020-09-16 18:05:07,533] ERROR: {'success': False, 'message': 'AuthenticationManager was not able to authenticate with provided tokens or user credentials!'} 127.0.0.1 - - [2020-09-16 18:05:07] "GET /auth/refresh HTTP/1.1" 500 251 0.002485 127.0.0.1 - - [2020-09-16 18:05:14] "GET /versions HTTP/1.1" 200 220 0.069836 127.0.0.1 - - [2020-09-16 18:05:14] "GET /auth HTTP/1.1" 200 252 0.001462 [2020-09-16 18:05:14,979] WARNING: Token Auth failed: No valid RefreshToken. Attempting auth via credentials [2020-09-16 18:05:14,979] ERROR: {'success': False, 'message': 'AuthenticationManager was not able to authenticate with provided tokens or user credentials!'} 127.0.0.1 - - [2020-09-16 18:05:14] "GET /auth/refresh HTTP/1.1" 500 251 0.002059 127.0.0.1 - - [2020-09-16 18:05:17] "GET /device HTTP/1.1" 200 511 2.527767 127.0.0.1 - - [2020-09-16 18:05:17] "GET /device/FD003B9C19AD9054 HTTP/1.1" 200 489 0.003843 127.0.0.1 - - [2020-09-16 18:05:17] "GET /auth HTTP/1.1" 200 252 0.003140 [2020-09-16 18:05:17,564] WARNING: Token Auth failed: No valid RefreshToken. Attempting auth via credentials [2020-09-16 18:05:17,565] ERROR: {'success': False, 'message': 'AuthenticationManager was not able to authenticate with provided tokens or user credentials!'} 127.0.0.1 - - [2020-09-16 18:05:17] "GET /auth/refresh HTTP/1.1" 500 251 0.004314 127.0.0.1 - - [2020-09-16 18:05:17] "GET /auth HTTP/1.1" 200 252 0.001953 [2020-09-16 18:05:17,606] WARNING: Token Auth failed: No valid RefreshToken. Attempting auth via credentials [2020-09-16 18:05:17,607] ERROR: {'success': False, 'message': 'AuthenticationManager was not able to authenticate with provided tokens or user credentials!'}