From 023f7bd054314dd44514a67d84ccaf761e8dc7fc Mon Sep 17 00:00:00 2001 From: Jarrett Lusso Date: Fri, 30 May 2025 19:20:59 -0400 Subject: [PATCH] Change authentication priority The `api_key` or `access_token` passed into a request will take priority over the globally configured API key. --- lib/emailable/client.rb | 2 +- test/authentication_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/emailable/client.rb b/lib/emailable/client.rb index a61369f..e738740 100644 --- a/lib/emailable/client.rb +++ b/lib/emailable/client.rb @@ -22,7 +22,7 @@ def request(method, endpoint, params = {}) uri = URI("#{@base_url}/#{endpoint}") headers = { - 'Authorization': "Bearer #{Emailable.api_key || api_key || access_token}", + 'Authorization': "Bearer #{api_key || access_token || Emailable.api_key}", 'Content-Type': 'application/json' } diff --git a/test/authentication_test.rb b/test/authentication_test.rb index 7ec2f82..1692754 100644 --- a/test/authentication_test.rb +++ b/test/authentication_test.rb @@ -24,4 +24,10 @@ def test_request_time_api_key_authentication refute_nil Emailable::Batch.new(bid).status(api_key: @api_key).id end + def test_request_time_authentication_takes_priority_over_global + Emailable.api_key = 'invalid_api_key' + + refute_nil Emailable.verify(@email, api_key: @api_key).domain + end + end