Skip to content

Commit 1d30b7b

Browse files
committed
Fix #5
1 parent 98ef31f commit 1d30b7b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Supabase/Client.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public static Client Instance
5252
public string AuthUrl { get; private set; }
5353
public string Schema { get; private set; }
5454

55+
private SupabaseOptions options;
56+
5557
private Client() { }
5658

5759

@@ -88,6 +90,7 @@ public static async Task<Client> InitializeAsync(string supabaseUrl, string supa
8890
if (options == null)
8991
options = new SupabaseOptions();
9092

93+
instance.options = options;
9194
instance.RestUrl = string.Format(options.RestUrlFormat, supabaseUrl);
9295
instance.RealtimeUrl = string.Format(options.RealtimeUrlFormat, supabaseUrl).Replace("http", "ws");
9396
instance.AuthUrl = string.Format(options.AuthUrlFormat, supabaseUrl);
@@ -139,10 +142,18 @@ public static async Task<Client> InitializeAsync(string supabaseUrl, string supa
139142
internal Dictionary<string, string> GetAuthHeaders()
140143
{
141144
var headers = new Dictionary<string, string>();
142-
var bearer = Auth?.CurrentSession?.AccessToken != null ? Auth.CurrentSession.AccessToken : SupabaseKey;
143-
144145
headers["apiKey"] = SupabaseKey;
145-
headers["Authorization"] = $"Bearer {bearer}";
146+
147+
// In Regard To: https://github.com/supabase/supabase-csharp/issues/5
148+
if (options.Headers.ContainsKey("Authorization"))
149+
{
150+
headers["Authorization"] = options.Headers["Authorization"];
151+
}
152+
else
153+
{
154+
var bearer = Auth?.CurrentSession?.AccessToken != null ? Auth.CurrentSession.AccessToken : SupabaseKey;
155+
headers["Authorization"] = $"Bearer {bearer}";
156+
}
146157

147158
return headers;
148159
}

0 commit comments

Comments
 (0)