Skip to content

Commit

Permalink
Merge pull request #62 from sergemat/master
Browse files Browse the repository at this point in the history
Fixed issue with HTTP status code 502 when creating Yahoo session.
  • Loading branch information
sergemat committed Dec 10, 2023
2 parents cc30b5f + ca95578 commit fea36c9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion YahooFinanceApi/YahooSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Threading.Tasks;
using System;
using System.Threading;
using System.Linq;

namespace YahooFinanceApi
{
Expand Down Expand Up @@ -62,11 +63,14 @@ public static async Task InitAsync(CancellationToken token = default)

var response = await "https://fc.yahoo.com"
.AllowHttpStatus("404")
.AllowHttpStatus("502")
.WithHeader(userAgentKey, userAgentValue)
.GetAsync()
.ConfigureAwait(false);

if (response.Cookies.Count == 0)
_cookie = response.Cookies.FirstOrDefault(c => c.Name == "A3");

if (_cookie == null)
{
throw new Exception("Failed to obtain Yahoo auth cookie.");
}
Expand Down

0 comments on commit fea36c9

Please sign in to comment.