Skip to content

Commit

Permalink
Store SID cookie
Browse files Browse the repository at this point in the history
The SID cookie is used to ensure that the client "owns" their given checkForm token. If used in multiple HttpClients, they can all share an API token.
  • Loading branch information
TrevTV committed Aug 18, 2024
1 parent 4de34f4 commit e7b04a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion DeezNET/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public DeezerClient()
{
_arl = "";

_client = new HttpClient();
_clientHandler = new() { CookieContainer = new() };
_client = new HttpClient(_clientHandler);
_client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.5");

_gwApi = new(_client, _arl);
Expand Down Expand Up @@ -42,10 +43,13 @@ public async Task SetARL(string arl)
public GWApi GWApi { get => _gwApi; }
public PublicApi PublicApi { get => _publicApi; }
public string ActiveARL { get => _arl; }
public string SID { get => _clientHandler.CookieContainer.GetCookies(_deezerUri).FirstOrDefault(c => c.Name == "sid")?.Value ?? ""; }

private Downloader _downloader;
private HttpClient _client;
private GWApi _gwApi;
private PublicApi _publicApi;
private string _arl;
private HttpClientHandler _clientHandler;
private readonly Uri _deezerUri = new("https://deezer.com");
}
2 changes: 1 addition & 1 deletion DeezNET/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<Company>TrevTV</Company>
<Copyright>Copyright (C) Trevor Jackson</Copyright>
<LangVersion>latest</LangVersion>
Expand Down

0 comments on commit e7b04a3

Please sign in to comment.