Skip to content

Commit

Permalink
Merge pull request #97 from noriokun4649/fix_nicologin
Browse files Browse the repository at this point in the history
Niconico login fix #96
  • Loading branch information
noriokun4649 committed Mar 6, 2024
2 parents 48fcc30 + dc80dbc commit c8866f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions TVTComment/Model/NiconicoUtils/NiconicoLoginSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Reflection;
using System.Threading.Tasks;

namespace TVTComment.Model.NiconicoUtils
Expand Down Expand Up @@ -125,6 +126,9 @@ public async Task Login()
var twofactorHandler = new HttpClientHandler();
twofactorHandler.CookieContainer.Add(loginCookie);
using var twofactor = new HttpClient(twofactorHandler);
var assembly = Assembly.GetExecutingAssembly().GetName();
var ua = assembly.Name + "/" + assembly.Version.ToString(3);
twofactor.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", ua);
var twofactorRes = await twofactor.PostAsync(location,twofactorContent).ConfigureAwait(false);
userid = twofactorRes.Headers.GetValues("x-niconico-id").FirstOrDefault();
handler.CookieContainer.Add(twofactorHandler.CookieContainer.GetCookies(new Uri(location)));
Expand Down

0 comments on commit c8866f3

Please sign in to comment.