shawty_ds 0 Posted March 3, 2019 Share Posted March 3, 2019 Hi All, Having a play with the Emby .NET C# API, just to see what I can do with it. (I have a few ideas, but want to explore a bit first) Not a beginner in C# by any stretch of the imagination, but first time I've ever tried to work against the Emby API. Following the samples here: https://github.com/MediaBrowser/Emby.ApiClient Specifically the API auth example (The signature on the ApiClient doesn't seem to match the first sample anymore) As far as I can see, my code is exactly the same as whats on the github page, bar the API key, but every time I try to new up an ApiClient I get a null ref exception. As far as I can see, all my variables have contents, the only two that don't, haven't been newed up yet as they depend on the ApiClient call. I'm using Visual Studio Enterprise 2017, with a dotnetcore 2.2 console mode application as my test, and I've used NuGet to get the latest EmbyAPi from nuget, Any ideas? Shawty Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 4, 2019 Share Posted March 4, 2019 Hi, can you find out exactly what is null that is not supposed to be? Thanks ! Link to comment Share on other sites More sharing options...
shawty_ds 0 Posted March 5, 2019 Author Share Posted March 5, 2019 I've been having a nosy, and can't seem to see anything. The only way i'd be able to get any deeper would be to build the libs from source and trace into them that way instead of just adding them via nuget. I won't have time to do that until the weekend. Link to comment Share on other sites More sharing options...
BillOatman 500 Posted March 6, 2019 Share Posted March 6, 2019 (edited) This is my code that works, hope it helps. But is it able to resolve "embyserver" when it executes? I use my servers IP address instead of a DNS name. var device = new Device { DeviceName = "My Device Name", DeviceId = "My Device Id" }; var logger = new Logger(); var cryptoProvider = new CryptographyProvider(); var client = new ApiClient(logger, "http://" + ip + ":" + port, "GuideRefresh", device, System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), cryptoProvider); var authResult = await client.AuthenticateUserAsync(user, pass); Edited March 6, 2019 by BillOatman Link to comment Share on other sites More sharing options...
Luke 37067 Posted March 7, 2019 Share Posted March 7, 2019 You may actually want to run from source right now as the library has updates that haven't been pushed to nuget yet. thanks. Link to comment Share on other sites More sharing options...
Statick 7 Posted February 13, 2022 Share Posted February 13, 2022 Having some trouble getting the API to authenticate and found this thread. Noticed that the Nuget package is dated 2017 - any possibility of getting this updated? Link to comment Share on other sites More sharing options...
Statick 7 Posted February 13, 2022 Share Posted February 13, 2022 so I just uninstalled the Nuget package and cloned the github repo, rebuilt my project using that, made no other modifications whatsoever, and after a week of banging my head against unexplainable authentication errors it now works perfectly I think it would be good to update the Nuget as it's years out of date and clearly not functional, or at least put a note on the wiki that the Nuget package doesn't work Link to comment Share on other sites More sharing options...
roaku 795 Posted February 13, 2022 Share Posted February 13, 2022 (edited) 45 minutes ago, Statick said: so I just uninstalled the Nuget package and cloned the github repo, rebuilt my project using that, made no other modifications whatsoever, and after a week of banging my head against unexplainable authentication errors it now works perfectly I think it would be good to update the Nuget as it's years out of date and clearly not functional, or at least put a note on the wiki that the Nuget package doesn't work I'm curious what 'Nuget package' you were using. This one is very up to date and works fine: https://www.nuget.org/packages/MediaBrowser.Server.Core Edit: Ah, I guess you're using the ApiClient package in a non-plugin context. Nevermind. Edited February 13, 2022 by roaku Link to comment Share on other sites More sharing options...
Statick 7 Posted February 13, 2022 Share Posted February 13, 2022 yeah that's it, using the api client. I adapted the example code but couldn't get it to authenticate at all, until I found this thread which prompted me to uninstall nuget and use the code from github instead. after doing that it worked perfectly Link to comment Share on other sites More sharing options...
chef 3745 Posted February 14, 2022 Share Posted February 14, 2022 I was tired using the c# API libraries not long ago, and Luke had mentioned that they hadn't been updated in a while. He suggested using the JavaScript libraries instead. I used them in a node app and everything worked quite well. I also banged out the "Posters" app using them in a web environment, and it was super easy, barely an inconvenience. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now