Trakt token expiry (1 Viewer)

ajs

Development Group
  • Team MediaPortal
  • February 29, 2008
    16,851
    12,105
    Kyiv
    Home Country
    Ukraine Ukraine
    It might happen today, but there is no normal output of information in case of failure, it might have to be redone.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,851
    12,105
    Kyiv
    Home Country
    Ukraine Ukraine
    I caught it, but I don't understand why yet.

    Code:
    2025-09-16 20:49:11.333 [INFO] [Sync][36]: The trakt access token has now expired as of 15.09.2025 19:37:41, requesting refresh token
    2025-09-16 20:49:11.343 [DEBG] [Sync][36]: Address: https://api.trakt.tv/oauth/token, Post: {"client_id":"client-id","client_secret":"secret","grant_type":"refresh_token","redirect_uri":"urn:ietf:wg:oauth:2.0:oob","refresh_token":"token"}
    2025-09-16 20:49:11.810 [DEBG] [Sync][36]: Response: {"access_token":"token","token_type":"Bearer","expires_in":86399,"refresh_token":"token","scope":"public","created_at":1758044955}, Headers: {Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: 9802330daae4ef1a-WAW, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, content-security-policy: frame-ancestors 'self' https://trakt.tv https://*.trakt.tv http://localhost:* https://localhost:*;, pragma: no-cache, vary: Accept-Encoding, x-ratelimit: {"name":"AUTHED_API_POST_LIMIT","period":1,"limit":1,"remaining":0,"until":"2025-09-16T17:49:16Z"}, x-request-id: 429051fb-8b7b-437f-b0f2-06b3d849b208, x-runtime: 0.025655, cf-cache-status: DYNAMIC, alt-svc: h3=":443"; ma=86400, Cache-Control: no-store, Content-Type: application/json; charset=utf-8, Date: Tue, 16 Sep 2025 17:49:15 GMT, ETag: W/"cd4fae994217edd8265c240b1b368e77", Set-Cookie: _traktsession=session; path=/; HttpOnly; SameSite=Lax, Server: cloudflare}
    2025-09-16 20:49:11.830 [DEBG] [Sync][36]: Address: https://api.trakt.tv/users/settings
    2025-09-16 20:49:12.385 [DEBG] [Sync][36]: Response: {"user":{"username":"ajs","private":true,"deleted":false,"name":"Andrew J.Swan","vip":false,"vip_ep":false,"director":false,"ids":{"slug":"ajs","uuid":"6a535fb08d5ef71067961a436ee0598eeaf294aa"},"joined_at":"2011-07-08T20:54:45.000Z","location":"Kiev","about":"-|-","gender":"male","age":50,"images":{"avatar":{"full":"https://walter-r2.trakt.tv/images/users/000/013/623/avatars/large/c47a2ea690.jpg"}},"vip_og":false,"vip_years":0,"vip_cover_image":null},"account":{"timezone":"Europe/Kiev","date_format":"dmy","time_24hr":true,"cover_image":null,"token":null,"display_ads":true},"connections":{"facebook":false,"twitter":true,"mastodon":false,"google":true,"tumblr":false,"medium":false,"slack":false,"apple":false,"dropbox":false,"microsoft":false},"sharing_text":{"watching":"I'm watching [item]","watched":"I just watched [item]","rated":null},"limits":{"list":{"count":10,"item_count":100},"watchlist":{"item_count":100},"favorites":{"item_count":100},"search":{"recent_count":5},"collection":{"item_count":100},"notes":{"item_count":100},"recommendations":{"item_count":100}},"permissions":{"commenting":true,"liking":true,"following":true}}, Headers: {Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: 9802330f6f29ef1a-WAW, x-frame-options: SAMEORIGIN, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, vary: Accept-Encoding, x-ratelimit: {"name":"AUTHED_API_GET_LIMIT","period":300,"limit":1000,"remaining":999,"until":"2025-09-16T17:50:00Z"}, x-request-id: d9c84f6a-61ca-4784-b93e-110566415df4, x-runtime: 0.368244, cf-cache-status: DYNAMIC, speculation-rules: "/cdn-cgi/speculation", alt-svc: h3=":443"; ma=86400, Cache-Control: max-age=0, private, must-revalidate, Content-Type: application/json; charset=utf-8, Date: Tue, 16 Sep 2025 17:49:16 GMT, ETag: W/"etag", Server: cloudflare}
    2025-09-16 20:49:12.387 [INFO] [Sync][36]: User ajs successfully signed in and retrieved online settings from trakt.tv

    Code:
    2025-09-17 21:01:09.612 [INFO] [PlaySync][44]: The trakt access token has now expired as of 15.09.2025 19:37:41, requesting refresh token
    2025-09-17 21:01:09.621 [DEBG] [PlaySync][44]: Address: https://api.trakt.tv/oauth/token, Post: {"client_id":"private","client_secret":"private","grant_type":"refresh_token","redirect_uri":"urn:ietf:wg:oauth:2.0:oob","refresh_token":"token"}
    2025-09-17 21:01:10.184 [ERR ] [PlaySync][44]: Protocol Error, Code = '400', Description = 'Bad Request', Url = 'https://api.trakt.tv/oauth/token', Headers = 'Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: id-WAW, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, content-security-policy: frame-ancestors 'self' https://trakt.tv https://*.trakt.tv http://localhost:* https://localhost:*;, vary: Accept-Encoding, x-ratelimit: {"name":"AUTHED_API_POST_LIMIT","period":1,"limit":1,"remaining":0,"until":"2025-09-17T18:01:15Z"}, x-request-id: request-id, x-runtime: 0.005531, cf-cache-status: DYNAMIC, alt-svc: h3=":443"; ma=86400, Cache-Control: no-store, Content-Type: application/json; charset=utf-8, Date: Wed, 17 Sep 2025 18:01:15 GMT, Set-Cookie: _traktsession=session-id; path=/; HttpOnly; SameSite=Lax, Server: cloudflare, WWW-Authenticate: Bearer realm="Trakt", error="invalid_grant", error_description="The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."'
    2025-09-17 21:01:10.210 [ERR ] [PlaySync][44]: Failed to refresh access token from trakt.tv, you must go to settings and re-authorise application, Code = '400', Reason = 'Bad Request'
    ...
    2025-09-17 22:39:50.788 [INFO] [Trakt][65]: Getting device code from trakt.tv
    2025-09-17 22:39:50.802 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/code, Post: {"client_id":"private"}
    2025-09-17 22:39:51.012 [DEBG] [Trakt][65]: Response: {"device_code":"private","user_code":"user","verification_url":"https://trakt.tv/activate","expires_in":600,"interval":5}, Headers: {Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: id-WAW, x-frame-options: SAMEORIGIN, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, vary: Accept-Encoding, x-request-id: request-id, x-runtime: 0.009348, cf-cache-status: DYNAMIC, alt-svc: h3=":443"; ma=86400, Cache-Control: max-age=0, private, must-revalidate, Content-Type: application/json; charset=utf-8, Date: Wed, 17 Sep 2025 19:39:55 GMT, ETag: W/"etag", Set-Cookie: _traktsession=session-id; path=/; HttpOnly; SameSite=Lax, Server: cloudflare}
    2025-09-17 22:39:51.021 [INFO] [Trakt][65]: Successfully got device code from trakt.tv, presenting code 'user' to user for activation at 'https://trakt.tv/activate'. Code expires in '600' secs
    2025-09-17 22:39:51.022 [INFO] [Trakt][65]: Polling trakt.tv for authorisation token every '5' secs until user enters code
    2025-09-17 22:39:51.026 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:39:56.269 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:01.530 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:06.740 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:11.986 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:17.221 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:22.459 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:27.701 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:32.924 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:38.151 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/oauth/device/token, Post: {"client_id":"private","client_secret":"private","code":"private"}
    2025-09-17 22:40:38.372 [DEBG] [Trakt][65]: Response: {"access_token":"token","token_type":"bearer","expires_in":86400,"refresh_token":"token","scope":"public","created_at":1758138038}, Headers: {Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: 980b13b0a81cbf7b-WAW, x-frame-options: SAMEORIGIN, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, vary: Accept-Encoding, x-request-id: request-id, x-runtime: 0.009469, cf-cache-status: DYNAMIC, alt-svc: h3=":443"; ma=86400, Cache-Control: max-age=0, private, must-revalidate, Content-Type: application/json; charset=utf-8, Date: Wed, 17 Sep 2025 19:40:43 GMT, ETag: W/"etag", Set-Cookie: _traktsession=session-id; path=/; HttpOnly; SameSite=Lax, Server: cloudflare}
    2025-09-17 22:40:38.380 [DEBG] [Trakt][65]: Address: https://api.trakt.tv/users/settings
    2025-09-17 22:40:38.684 [DEBG] [Trakt][65]: Response: {"user":{"username":"ajs","private":true,"deleted":false,"name":"Andrew J.Swan","vip":false,"vip_ep":false,"director":false,"ids":{"slug":"ajs","uuid":"uuid"},"joined_at":"2011-07-08T20:54:45.000Z","location":"Kiev","about":"-|-","gender":"male","age":50,"images":{"avatar":{"full":"https://walter-r2.trakt.tv/images/users/000/013/623/avatars/large/c47a2ea690.jpg"}},"vip_og":false,"vip_years":0,"vip_cover_image":null},"account":{"timezone":"Europe/Kiev","date_format":"dmy","time_24hr":true,"cover_image":null,"token":null,"display_ads":true},"connections":{"facebook":false,"twitter":true,"mastodon":false,"google":true,"tumblr":false,"medium":false,"slack":false,"apple":false,"dropbox":false,"microsoft":false},"sharing_text":{"watching":"I'm watching [item]","watched":"I just watched [item]","rated":null},"limits":{"list":{"count":10,"item_count":100},"watchlist":{"item_count":100},"favorites":{"item_count":100},"search":{"recent_count":5},"collection":{"item_count":100},"notes":{"item_count":100},"recommendations":{"item_count":100}},"permissions":{"commenting":true,"liking":true,"following":true}}, Headers: {Transfer-Encoding: chunked, Connection: keep-alive, CF-RAY: etag-WAW, x-frame-options: SAMEORIGIN, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, vary: Accept-Encoding, x-ratelimit: {"name":"AUTHED_API_GET_LIMIT","period":300,"limit":1000,"remaining":999,"until":"2025-09-17T19:45:00Z"}, x-request-id: id, x-runtime: 0.121578, cf-cache-status: DYNAMIC, speculation-rules: "/cdn-cgi/speculation", alt-svc: h3=":443"; ma=86400, Cache-Control: max-age=0, private, must-revalidate, Content-Type: application/json; charset=utf-8, Date: Wed, 17 Sep 2025 19:40:43 GMT, ETag: W/"etag", Server: cloudflare}
    2025-09-17 22:40:38.729 [INFO] [Trakt][65]: Saving settings
     
    Last edited:

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,851
    12,105
    Kyiv
    Home Country
    Ukraine Ukraine
    I asked a question, but so far there is silence.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,851
    12,105
    Kyiv
    Home Country
    Ukraine Ukraine
    You may have to open a new ticket
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,990
    3,711
    Nuenen
    Home Country
    Netherlands Netherlands
    i think (at least from my short investigation) that the token validity is only checked when MP/Trakt is started.
    If MP is running long then it may also expire during usage.
    F.e. Started MP at 12:50 and at around 22:15 i watched a series and got the error:
    Code:
    2025-11-05 22:13:02.131 [DEBG] [OnlineVideosTracking][27]: Received Video Playback event from OnlineVideos
    2025-11-05 22:13:02.148 [DEBG] [Scrobble][49]: Address: https://api.trakt.tv/scrobble/start, Post: {"app_date":"2024-09-30","app_version":"6.0.5.364","progress":0,"episode":{"ids":{"slug":null,"trakt":null,"imdb":null,"tmdb":null,"tvdb":null,"tvrage":null},"number":2,"season":28,"title":null},"show":{"ids":{"slug":null,"trakt":null,"imdb":"0121955","tmdb":null,"tvdb":null,"tvrage":null},"title":"South Park","year":null}}
    2025-11-05 22:13:02.338 [ERR ] [Scrobble][49]: Protocol Error, Code = '401', Description = 'Unauthorized', Url = 'https://api.trakt.tv/scrobble/start', Headers = 'Transfer-Encoding: chunked, Connection: keep-alive, x-frame-options: SAMEORIGIN, x-xss-protection: 0, x-content-type-options: nosniff, x-download-options: noopen, x-permitted-cross-domain-policies: none, referrer-policy: strict-origin-when-cross-origin, vary: Accept-Encoding, x-ratelimit: {"name":"AUTHED_API_POST_LIMIT","period":1,"limit":1,"remaining":0,"until":"2025-11-05T21:13:04Z"}, Server-Timing: cfCacheStatus;desc="DYNAMIC",cfEdge;dur=10,cfOrigin;dur=136, x-request-id: f61ca3bd-5c58-4742-b171-e37cb542cb3c, x-runtime: 0.042113, cf-cache-status: DYNAMIC, CF-RAY: 999f5a54ea7ef5db-AMS, alt-svc: h3=":443"; ma=86400, Cache-Control: max-age=0, private, must-revalidate, no_store=true, no_cache=true, Content-Type: text/html, Date: Wed, 05 Nov 2025 21:13:03 GMT, Set-Cookie: _traktsession=<redacted>; HttpOnly; SameSite=Lax; Path=/, Server: cloudflare, WWW-Authenticate: Bearer realm="Trakt", error="invalid_token", error_description="The access token expired"'

    So we should implement getting a fresh one in case of 401's

    Edit: Just to clarify: this is normal behavior and isn't tied to shorter expiry dates at all.
    Only if the token is expired before startup of MP it's renewed, when it expires between startup and watching something its going to give that error.
    Working on a fix now
     
    Last edited:

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,990
    3,711
    Nuenen
    Home Country
    Netherlands Netherlands
    right, I made some improvements (not yet committed) and just too late, my token expired this morning so if I install the new trakt plugin it will refresh at startup and have to wait another week to see if it actually works :(

    in the mean time: @ajs what is the procedure for releasing?
    - commit to GitHub - Mediaportal-Plugin-Team/Trakt-for-Mediaportal: Adds Trakt Support to Mediaportal
    or
    - make a PR for GitHub - Mediaportal-Plugin-Team/Trakt-for-Mediaportal: Adds Trakt Support to Mediaportal
    or
    - make a PR for GitHub - trakt/Trakt-for-Mediaportal: Adds Trakt Support to Mediaportal
    and how is that build/release triggered?
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,851
    12,105
    Kyiv
    Home Country
    Ukraine Ukraine
    Any change (no matter how it happened) in Trakt-for-Mediaportal/MPEI/TraktInstaller.xmp2 at master · Mediaportal-Plugin-Team/Trakt-for-Mediaportal will result in MPE1 being built and published.
    Look:
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,990
    3,711
    Nuenen
    Home Country
    Netherlands Netherlands
    thanks, and how about committing the code?
    • which repo (original or our Mediaportal-plugin-team)
    • just commit to master or make PR for review?
     

    Users who are viewing this thread

    Top Bottom