pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/

update redirect uri logic

Pas f0dde1e7 1bb1e2f9

+15 -21
+1 -5
src/components/TraktAuthHandler.tsx
··· 19 19 setStatus("syncing"); 20 20 setError(null); 21 21 try { 22 - const redirectUri = `${window.location.origin}${window.location.pathname}`; 23 - const success = await traktService.exchangeCodeForToken( 24 - code, 25 - redirectUri, 26 - ); 22 + const success = await traktService.exchangeCodeForToken(code); 27 23 if (success) { 28 24 const newParams = new URLSearchParams(searchParams); 29 25 newParams.delete("code");
+7 -5
src/pages/parts/settings/ConnectionsPart.tsx
··· 780 780 const config = conf(); 781 781 782 782 const connect = () => { 783 - const redirectUri = 784 - config.TRAKT_REDIRECT_URI ?? 785 - `${window.location.origin}${window.location.pathname}`; 786 783 const params = new URLSearchParams({ 787 784 response_type: "code", 788 785 client_id: config.TRAKT_CLIENT_ID ?? "", 789 - redirect_uri: redirectUri, 786 + redirect_uri: config.TRAKT_REDIRECT_URI ?? "", 790 787 }); 791 788 window.location.href = `https://trakt.tv/oauth/authorize?${params.toString()}`; 792 789 }; 793 790 794 - if (!config.TRAKT_CLIENT_ID || !config.TRAKT_CLIENT_SECRET) return null; 791 + if ( 792 + !config.TRAKT_CLIENT_ID || 793 + !config.TRAKT_CLIENT_SECRET || 794 + !config.TRAKT_REDIRECT_URI 795 + ) 796 + return null; 795 797 796 798 return ( 797 799 <SettingsCard>
+7 -11
src/utils/trakt.ts
··· 45 45 }&redirect_uri=${encodeURIComponent(config.TRAKT_REDIRECT_URI)}`; 46 46 } 47 47 48 - public async exchangeCodeForToken( 49 - code: string, 50 - redirectUri?: string, 51 - ): Promise<boolean> { 48 + public async exchangeCodeForToken(code: string): Promise<boolean> { 52 49 const config = conf(); 53 - if (!config.TRAKT_CLIENT_ID || !config.TRAKT_CLIENT_SECRET) 50 + if ( 51 + !config.TRAKT_CLIENT_ID || 52 + !config.TRAKT_CLIENT_SECRET || 53 + !config.TRAKT_REDIRECT_URI 54 + ) 54 55 throw new Error("Missing Trakt config"); 55 - 56 - const resolvedRedirectUri = 57 - redirectUri ?? config.TRAKT_REDIRECT_URI ?? undefined; 58 - if (!resolvedRedirectUri) 59 - throw new Error("Missing redirect_uri for token exchange"); 60 56 61 57 try { 62 58 const data = await ofetch(`${TRAKT_API_URL}/oauth/token`, { ··· 66 62 code, 67 63 client_id: config.TRAKT_CLIENT_ID, 68 64 client_secret: config.TRAKT_CLIENT_SECRET, 69 - redirect_uri: resolvedRedirectUri, 65 + redirect_uri: config.TRAKT_REDIRECT_URI, 70 66 grant_type: "authorization_code", 71 67 }, 72 68 });