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