Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/bloomy/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
from pathlib import Path
from typing import TYPE_CHECKING
from urllib.parse import urlencode

import httpx
import yaml
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down