Add trakt in the list of supported oidc

This commit is contained in:
Zoe Roux 2024-03-24 14:23:03 +01:00
parent 1cd3704bc3
commit 95bc5b9f7c
No known key found for this signature in database
3 changed files with 19 additions and 1 deletions

View File

@ -41,7 +41,7 @@ THEMOVIEDB_APIKEY=
# The url you can use to reach your kyoo instance. This is used during oidc to redirect users to your instance.
PUBLIC_URL=http://localhost:5000
# Use a builtin oidc service (google, discord, or simkl):
# Use a builtin oidc service (google, discord, trakt, or simkl):
# When you create a client_id, secret combo you may be asked for a redirect url. You need to specify https://YOUR-PUBLIC-URL/api/auth/logged/YOUR-SERVICE-NAME
OIDC_DISCORD_CLIENTID=
OIDC_DISCORD_SECRET=

View File

@ -63,8 +63,12 @@ public class JwtProfile
{
if (value is null)
return;
// trakt store their name there (they also store name but that's not the same).
Username ??= value["username"]?.ToString();
// simkl store their name there.
Username ??= value["name"]?.ToString();
Sub ??= value["ids"]?["uuid"]?.ToString();
}
}

View File

@ -148,5 +148,19 @@ public class OidcProvider
GetExtraHeaders = (OidcProvider self) =>
new() { ["simkl-api-key"] = self.ClientId },
},
["trakt"] = new("trakt")
{
DisplayName = "Trakt",
LogoUrl = "https://logo.clearbit.com/trakt.tv",
AuthorizationUrl = "https://api.trakt.tv/oauth/authorize",
TokenUrl = "https://api.trakt.tv/oauth/token",
ProfileUrl = "https://api.trakt.tv/users/settings",
// does not seems to have scopes
Scope = null,
TokenUseJsonBody = true,
GetProfileUrl = (profile) => $"https://trakt.tv/users/{profile.Username}",
GetExtraHeaders = (OidcProvider self) =>
new() { ["trakt-api-key"] = self.ClientId, ["trakt-api-version"] = "2", },
},
};
}