c# - ASP.NET Core Authenticating Clients (Console/WPF) -
i've searched far , wide working (simple) solution authentication in asp.net core date. sorry if have missed , if has provided solution, here comes question:
i've buil asp.net core mvc/api solution identity/ef cookieauthentication. can log in/out in mvc , set claims/roles user.
i have wpf client whom i'd authenticate , connect api. far have attempted use httpclient sign in same way in asp.net - signinmanager credentials. how persist session/cookie/token wpf client future httprequests authenticated through built in identity?
have tried deriving own webclient
public class myclient : webclient { private readonly cookiecontainer _container = new cookiecontainer(); protected override webrequest getwebrequest(uri address) { httpwebrequest request = (httpwebrequest)base.getwebrequest(address); if (request == null) throw new invalidoperationexception("request == null"); request.automaticdecompression = decompressionmethods.gzip | decompressionmethods.deflate; request.cookiecontainer = this._container; ... // add required cookies here? uri target = new uri("http://example.com"); this._container.add(new cookie("_spc", "aefec0ba-dc10-23e5-46f1-6b6e50c8837e") { domain = target.host }); return request; } }
Comments
Post a Comment