{"record":{"id":"cb402122b9b2ef57","repo":"nautechsystems/nautilus_trader","slug":"api-key-api-secret-api-passphrase-credenti","errorCode":null,"errorMessage":"`api_key`, `api_secret`, `api_passphrase` credentials must be provided together","messagePattern":"`api_key`, `api_secret`, `api_passphrase` credentials must be provided together","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/websocket/client.rs","lineNumber":340,"sourceCode":"    #[allow(clippy::too_many_arguments)]\n    pub fn new(\n        url: Option<String>,\n        api_key: Option<String>,\n        api_secret: Option<String>,\n        api_passphrase: Option<String>,\n        _account_id: Option<AccountId>,\n        heartbeat: Option<u64>,\n        auth_timeout_secs: Option<u64>,\n        transport_backend: TransportBackend,\n        proxy_url: Option<String>,\n    ) -> anyhow::Result<Self> {\n        let url = url.unwrap_or(OKX_WS_PUBLIC_URL.to_string());\n        let credential = match (api_key, api_secret, api_passphrase) {\n            (Some(key), Some(secret), Some(passphrase)) => {\n                Some(Credential::new(key, secret, passphrase))\n            }\n            (None, None, None) => None,\n            _ => anyhow::bail!(\n                \"`api_key`, `api_secret`, `api_passphrase` credentials must be provided together\"\n            ),\n        };\n\n        let signal = Arc::new(AtomicBool::new(false));\n        let subscriptions_inst_type = Arc::new(DashMap::new());\n        let subscriptions_inst_family = Arc::new(DashMap::new());\n        let subscriptions_inst_id = Arc::new(DashMap::new());\n        let subscriptions_bare = Arc::new(DashMap::new());\n        let subscriptions_state = SubscriptionState::new(OKX_WS_TOPIC_DELIMITER);\n\n        Ok(Self {\n            clock: get_atomic_clock_realtime(),\n            url,\n            vip_level: Arc::new(AtomicU8::new(0)),\n            credential,\n            heartbeat,\n            auth_timeout_secs: auth_timeout_secs.unwrap_or(AUTHENTICATION_TIMEOUT_SECS),","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/websocket/client.rs#L322-L358","documentation":"OKX WebSocket client construction validates that credentials are all-or-nothing: `api_key`, `api_secret`, and `api_passphrase` must each be supplied or all omitted. A partial set (e.g. key without passphrase) cannot authenticate with OKX, so `new` returns this error instead of building a client that would fail later.","triggerScenarios":"Calling `OKXWebSocketClient::new`/`connect`-facing constructor with exactly one or two of the three credential strings set to `Some`.","commonSituations":"Config files or env vars defining only some of `api_key`/`api_secret`/`api_passphrase` (commonly the passphrase is forgotten for OKX); copy-pasting public-client setup while leaving one credential set.","solutions":["Provide all three: `api_key`, `api_secret`, and `api_passphrase` together.","Or provide none of them to create a public (unauthenticated) client.","Check your config/env for a missing `api_passphrase` — OKX credentials require it and it is the most commonly omitted piece."],"exampleFix":"// before\nOKXWebSocketClient::new(Some(api_key), None, None, None, None, url).await?;\n// after\nOKXWebSocketClient::new(Some(api_key), Some(api_secret), Some(api_passphrase), None, None, url).await?;","handlingStrategy":"validation","validationCode":"let creds = [api_key.is_some(), api_secret.is_some(), api_passphrase.is_some()];\nif creds.iter().any(|&x| x) && !creds.iter().all(|&x| x) {\n    return Err(anyhow::anyhow!(\"api_key, api_secret, api_passphrase must be set together\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store all three OKX credentials (key, secret, passphrase) together in config/env.","Remember the passphrase is per-API-key and set at key creation time.","For public market data, deliberately pass None for all three."],"tags":["okx","websocket","credentials","validation"],"backgroundTag":"missing-credentials","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}