{"record":{"id":"3fa0a1f1b1a7e591","repo":"wasmerio/wasmer","slug":"no-token-provided-run-wasmer-login-specify","errorCode":null,"errorMessage":"no token provided - run 'wasmer login', specify --token=XXX, or set the WASMER_TOKEN env var","messagePattern":"no token provided - run 'wasmer login', specify --token=XXX, or set the WASMER_TOKEN env var","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/config/env.rs","lineNumber":183,"sourceCode":"        let client = wasmer_backend_api::WasmerClient::new_with_proxy(\n            registry_url,\n            &DEFAULT_WASMER_CLI_USER_AGENT,\n            proxy,\n        )?;\n\n        let client = if let Some(token) = self.token() {\n            client.with_auth_token(token)\n        } else {\n            client\n        };\n\n        Ok(client)\n    }\n\n    pub fn client(&self) -> Result<WasmerClient, anyhow::Error> {\n        let client = self.client_unauthennticated()?;\n        if client.auth_token().is_none() {\n            anyhow::bail!(\n                \"no token provided - run 'wasmer login', specify --token=XXX, or set the WASMER_TOKEN env var\"\n            );\n        }\n\n        Ok(client)\n    }\n}\n\nimpl Default for WasmerEnv {\n    fn default() -> Self {\n        Self {\n            wasmer_dir: super::DEFAULT_WASMER_DIR.clone(),\n            cache_dir: super::DEFAULT_WASMER_CACHE_DIR.clone(),\n            registry: None,\n            token: None,\n        }\n    }\n}","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/config/env.rs#L165-L201","documentation":"`WasmerEnv::client()` builds an API client via `client_unauthennticated()` and requires an auth token for authenticated endpoints. If the resolved client has no auth token, it bails telling the user the three supported token sources: `wasmer login`, the --token flag, or the WASMER_TOKEN env var. Without a token, calls like deploy, publish, or cron management cannot authenticate against the registry.","triggerScenarios":"Any command whose execute path calls `env.client()` (login_and_save consumers, configure_cdn_cache, toggle_cron_job, construct_manifest, etc.) while no token is available: never logged in, --token omitted, and WASMER_TOKEN unset/empty.","commonSituations":"Fresh machine or CI runner without credentials, running deploy/publish before `wasmer login`, CI secrets not exposing WASMER_TOKEN, or a token cleared by re-running config without login.","solutions":["Run `wasmer login` to authenticate interactively","Pass the token explicitly: `wasmer deploy --token=<TOKEN>`","Export the token: `export WASMER_TOKEN=<TOKEN>` (or set it as a CI secret)","Check `wasmer whoami` to confirm credentials are present before running commands"],"exampleFix":"// before (CI step)\n- run: wasmer deploy\n// after\n- run: wasmer deploy\n  env:\n    WASMER_TOKEN: ${{ secrets.WASMER_TOKEN }}","handlingStrategy":"validation","validationCode":"fn has_wasmer_token() -> bool {\n    std::env::var(\"WASMER_TOKEN\").map(|t| !t.is_empty()).unwrap_or(false)\n}\nif !has_wasmer_token() {\n    anyhow::bail!(\"set WASMER_TOKEN or run 'wasmer login' first\");\n}","typeGuard":null,"tryCatchPattern":"match env.client() {\n    Ok(client) => client,\n    Err(e) if e.to_string().contains(\"no token provided\") => {\n        eprintln!(\"Authenticate: wasmer login, --token=XXX, or WASMER_TOKEN env var\");\n        return Err(e);\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Run `wasmer login` once per machine; verify with `wasmer whoami`","In CI, always inject WASMER_TOKEN from a secret store","Fail fast in scripts when WASMER_TOKEN is unset before invoking wasmer commands"],"tags":["authentication","token","config","cli"],"backgroundTag":"missing-auth-token","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}