jellyfin / TMDbLib

C#.Net library for TheMovieDB
MIT License
344 stars 128 forks source link

Test API key #417

Closed foxi69 closed 1 year ago

foxi69 commented 1 year ago

Hi,

Is there anyway to test the api key is valid in code?

LordMike commented 1 year ago

You could always call AccountGetDetailsAsync. If this fails somehow, then the API key probably isn't valid.

You should get an UnauthorizedAccessException if it wasn't valid (versus a timeout or any other issue that might be)

foxi69 commented 1 year ago

Okay, can you help me how to do it?

TMDbLib.Objects.Authentication.GuestSessionRequiredException

TMDbClient client = new TMDbClient(tmdbApiKey);
var result = client.AccountGetDetailsAsync().Result;
LordMike commented 1 year ago

Maybe the GetConfig calls then?

foxi69 commented 1 year ago

Yes, it works thanks!