mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-09-23 19:30:45 +00:00
fix(platform): retain integration token environment key
This commit is contained in:
@@ -910,7 +910,7 @@ def _prompt_platform_token() -> str:
|
||||
)
|
||||
return str(
|
||||
click.prompt(
|
||||
click.style(" CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN", fg="cyan"),
|
||||
click.style(" CREWAI_PLATFORM_INTEGRATION_TOKEN", fg="cyan"),
|
||||
hide_input=True,
|
||||
prompt_suffix=click.style(" > ", fg="bright_white"),
|
||||
)
|
||||
@@ -1082,9 +1082,7 @@ def _setup_platform_auth(agents: list[dict[str, Any]]) -> str | None:
|
||||
"`pip install 'crewai[tools]'`."
|
||||
) from error
|
||||
|
||||
token = os.environ.get("CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN") or os.environ.get(
|
||||
"CREWAI_PLATFORM_INTEGRATION_TOKEN", ""
|
||||
)
|
||||
token = os.environ.get("CREWAI_PLATFORM_INTEGRATION_TOKEN", "")
|
||||
while True:
|
||||
if not token:
|
||||
token = _prompt_platform_token()
|
||||
@@ -1096,7 +1094,7 @@ def _setup_platform_auth(agents: list[dict[str, Any]]) -> str | None:
|
||||
)
|
||||
continue
|
||||
|
||||
os.environ["CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN"] = token
|
||||
os.environ["CREWAI_PLATFORM_INTEGRATION_TOKEN"] = token
|
||||
failed_apps, token_invalid = _validate_platform_apps(
|
||||
apps, ApplicationSelector, client_for_selector
|
||||
)
|
||||
@@ -1112,7 +1110,7 @@ def _setup_platform_auth(agents: list[dict[str, Any]]) -> str | None:
|
||||
replacement_token = _prompt_platform_revalidation_token()
|
||||
if replacement_token:
|
||||
token = replacement_token
|
||||
os.environ["CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN"] = token
|
||||
os.environ["CREWAI_PLATFORM_INTEGRATION_TOKEN"] = token
|
||||
|
||||
|
||||
# ── Main ────────────────────────────────────────────────────────
|
||||
@@ -1180,9 +1178,9 @@ def create_json_crew(
|
||||
copy_assistant_instructions(folder_path)
|
||||
|
||||
if platform_token:
|
||||
os.environ["CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN"] = platform_token
|
||||
os.environ["CREWAI_PLATFORM_INTEGRATION_TOKEN"] = platform_token
|
||||
env_vars = load_env_vars(folder_path)
|
||||
env_vars["CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN"] = platform_token
|
||||
env_vars["CREWAI_PLATFORM_INTEGRATION_TOKEN"] = platform_token
|
||||
write_env_file(folder_path, env_vars)
|
||||
_success("CrewAI Platform Enterprise Action Auth Token saved to .env")
|
||||
|
||||
|
||||
@@ -1042,7 +1042,7 @@ def test_json_create_saves_platform_token_to_env_file(tmp_path, monkeypatch):
|
||||
json_crew.create_json_crew("Platform Crew", skip_provider=True)
|
||||
|
||||
env_file = tmp_path / "platform_crew" / ".env"
|
||||
assert "CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN=token" in env_file.read_text()
|
||||
assert "CREWAI_PLATFORM_INTEGRATION_TOKEN=token" in env_file.read_text()
|
||||
|
||||
|
||||
def test_json_crew_uses_template_files():
|
||||
|
||||
@@ -3,14 +3,10 @@ import os
|
||||
|
||||
def get_platform_integration_token() -> str:
|
||||
"""Get the Platform Enterprise Action Auth Token from the environment."""
|
||||
token = (
|
||||
os.getenv("CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN")
|
||||
or os.getenv("CREWAI_PLATFORM_INTEGRATION_TOKEN")
|
||||
or ""
|
||||
)
|
||||
token = os.getenv("CREWAI_PLATFORM_INTEGRATION_TOKEN") or ""
|
||||
if not token:
|
||||
raise ValueError(
|
||||
"No Platform Enterprise Action Auth Token found, please set the "
|
||||
"CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN environment variable"
|
||||
"CREWAI_PLATFORM_INTEGRATION_TOKEN environment variable"
|
||||
)
|
||||
return token # TODO: Use context manager to get token
|
||||
|
||||
@@ -367,7 +367,7 @@ def test_clipper_client_requires_platform_integration_token(
|
||||
parameters={},
|
||||
)
|
||||
|
||||
with pytest.raises(ValueError, match="CREWAI_ENTERPRISE_ACTION_AUTH_TOKEN"):
|
||||
with pytest.raises(ValueError, match="CREWAI_PLATFORM_INTEGRATION_TOKEN"):
|
||||
ClipperClient().execute_action(tool, {})
|
||||
|
||||
mock_post.assert_not_called()
|
||||
|
||||
Reference in New Issue
Block a user