From 62887e76a8ba97507fdeda45819e8d4f96600db8 Mon Sep 17 00:00:00 2001 From: Pjort Kat Date: Thu, 25 Jul 2024 16:08:57 +0200 Subject: [PATCH 1/3] chore: Add custom headers from options in Client.cs --- Supabase/Client.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Supabase/Client.cs b/Supabase/Client.cs index 57a3012f..b607afaa 100644 --- a/Supabase/Client.cs +++ b/Supabase/Client.cs @@ -244,7 +244,7 @@ private void Auth_StateChanged(object sender, AuthState e) /// public Task Rpc(string procedureName, object? parameters) => _postgrest.Rpc(procedureName, parameters); - + /// public Task Rpc(string procedureName, object? parameters) => _postgrest.Rpc(procedureName, parameters); @@ -272,6 +272,13 @@ internal Dictionary GetAuthHeaders() headers["Authorization"] = $"Bearer {bearer}"; } + // Add custom headers from options + // This will overwrite any existing headers with the same key, not sure if that's the desired behavior + foreach (var (key, value) in _options.Headers) + { + headers[key] = value; + } + return headers; } } From 037d7de98e4d46111527e9cca3eaa3c96c3356c1 Mon Sep 17 00:00:00 2001 From: Pjort Kat Date: Thu, 25 Jul 2024 20:28:54 +0200 Subject: [PATCH 2/3] fixed to work with netstandard2.0 --- Supabase/Client.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Supabase/Client.cs b/Supabase/Client.cs index b607afaa..898e2ea1 100644 --- a/Supabase/Client.cs +++ b/Supabase/Client.cs @@ -274,9 +274,9 @@ internal Dictionary GetAuthHeaders() // Add custom headers from options // This will overwrite any existing headers with the same key, not sure if that's the desired behavior - foreach (var (key, value) in _options.Headers) + foreach (var kvp in _options.Headers) { - headers[key] = value; + headers[kvp.Key] = kvp.Value; } return headers; From 429ab5999fed944061c919a1e843e4ba8fdeb629 Mon Sep 17 00:00:00 2001 From: Joseph Schultz <9093699+acupofjose@users.noreply.github.com> Date: Thu, 25 Jul 2024 13:48:27 -0500 Subject: [PATCH 3/3] Update comments --- Supabase/Client.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Supabase/Client.cs b/Supabase/Client.cs index 898e2ea1..fecadf65 100644 --- a/Supabase/Client.cs +++ b/Supabase/Client.cs @@ -249,6 +249,9 @@ public Task Rpc(string procedureName, object? parameters) => public Task Rpc(string procedureName, object? parameters) => _postgrest.Rpc(procedureName, parameters); + /// + /// Produces dictionary of Headers that will be supplied to child clients. + /// internal Dictionary GetAuthHeaders() { var headers = new Dictionary @@ -257,9 +260,7 @@ internal Dictionary GetAuthHeaders() }; if (_supabaseKey != null) - { headers["apiKey"] = _supabaseKey; - } // In Regard To: https://github.com/supabase/supabase-csharp/issues/5 if (_options.Headers.TryGetValue("Authorization", out var header)) @@ -272,14 +273,11 @@ internal Dictionary GetAuthHeaders() headers["Authorization"] = $"Bearer {bearer}"; } - // Add custom headers from options - // This will overwrite any existing headers with the same key, not sure if that's the desired behavior + // Add supplied headers from `ClientOptions` by developer foreach (var kvp in _options.Headers) - { headers[kvp.Key] = kvp.Value; - } return headers; } } -} \ No newline at end of file +}