diff --git a/src/bloomy/configuration.py b/src/bloomy/configuration.py index 6312210..609a278 100644 --- a/src/bloomy/configuration.py +++ b/src/bloomy/configuration.py @@ -5,7 +5,6 @@ import os from pathlib import Path from typing import TYPE_CHECKING -from urllib.parse import urlencode import httpx import yaml @@ -81,14 +80,11 @@ def _fetch_api_key(self, username: str, password: str) -> str: with httpx.Client() as client: response = client.post( "https://app.bloomgrowth.com/Token", - headers={"Content-Type": "application/x-www-form-urlencoded"}, - content=urlencode( - { - "grant_type": "password", - "userName": username, - "password": password, - } - ), + data={ + "grant_type": "password", + "userName": username, + "password": password, + }, ) if not response.is_success: diff --git a/tests/test_configuration.py b/tests/test_configuration.py index b0bfdf6..899e695 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -69,7 +69,14 @@ def test_configure_api_key_success(self): config.configure_api_key("user", "pass") assert config.api_key == "new-api-key" - mock_client.post.assert_called_once() + mock_client.post.assert_called_once_with( + "https://app.bloomgrowth.com/Token", + data={ + "grant_type": "password", + "userName": "user", + "password": "pass", + }, + ) def test_configure_api_key_failure(self): """Test API key configuration with authentication failure."""