DSinapellido 7 Posted August 19, 2018 Share Posted August 19, 2018 I want to throw a 401 error whenever a user is not authenticated. For this, I included IHasResultFactory on my ServerEndpoint class class ServerEndpoint : IService, IHasResultFactory { public IHttpResultFactory ResultFactory { get; set; } public IRequest Request { get; set; } private readonly SimklApi _api; private readonly ILogger _logger; private readonly IJsonSerializer _json; public ServerEndpoint(SimklApi api, ILogger logger, IJsonSerializer json) { _api = api; _logger = logger; _json = json; } The thing is, I can't find the ThrowError function mentioned on https://github.com/MediaBrowser/Emby/wiki/Creating-Api-Endpoints I can't even find it on Github https://github.com/MediaBrowser/Emby.Common/blob/master/MediaBrowser.Controller/Net/IHttpResultFactory.cs How should, or how I can throw an http error if someone uses my Server Api Endpoint? Link to comment Share on other sites More sharing options...
Luke 37096 Posted August 19, 2018 Share Posted August 19, 2018 You can instead just add the [Authenticated] attribute to your ServerEndpoint class. Link to comment Share on other sites More sharing options...
DSinapellido 7 Posted August 20, 2018 Author Share Posted August 20, 2018 You can instead just add the [Authenticated] attribute to your ServerEndpoint class. But, Is there any way to use the ThrowError function or to return another HTTP Status code besides 200/500? Link to comment Share on other sites More sharing options...
Luke 37096 Posted August 20, 2018 Share Posted August 20, 2018 No, you don't get to pick your response code. 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