wasmerio/wasmer · error

no token provided - run 'wasmer login', specify --token=XXX,

Error message

no token provided - run 'wasmer login', specify --token=XXX, or set the WASMER_TOKEN env var

What it means

`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.

Source

Thrown at lib/cli/src/config/env.rs:183

        let client = wasmer_backend_api::WasmerClient::new_with_proxy(
            registry_url,
            &DEFAULT_WASMER_CLI_USER_AGENT,
            proxy,
        )?;

        let client = if let Some(token) = self.token() {
            client.with_auth_token(token)
        } else {
            client
        };

        Ok(client)
    }

    pub fn client(&self) -> Result<WasmerClient, anyhow::Error> {
        let client = self.client_unauthennticated()?;
        if client.auth_token().is_none() {
            anyhow::bail!(
                "no token provided - run 'wasmer login', specify --token=XXX, or set the WASMER_TOKEN env var"
            );
        }

        Ok(client)
    }
}

impl Default for WasmerEnv {
    fn default() -> Self {
        Self {
            wasmer_dir: super::DEFAULT_WASMER_DIR.clone(),
            cache_dir: super::DEFAULT_WASMER_CACHE_DIR.clone(),
            registry: None,
            token: None,
        }
    }
}

View on GitHub (pinned to 8c4b9ee9d3)

Solutions

  1. Run `wasmer login` to authenticate interactively
  2. Pass the token explicitly: `wasmer deploy --token=<TOKEN>`
  3. Export the token: `export WASMER_TOKEN=<TOKEN>` (or set it as a CI secret)
  4. Check `wasmer whoami` to confirm credentials are present before running commands

Example fix

// before (CI step)
- run: wasmer deploy
// after
- run: wasmer deploy
  env:
    WASMER_TOKEN: ${{ secrets.WASMER_TOKEN }}
Defensive patterns

Strategy: validation

Validate before calling

fn has_wasmer_token() -> bool {
    std::env::var("WASMER_TOKEN").map(|t| !t.is_empty()).unwrap_or(false)
}
if !has_wasmer_token() {
    anyhow::bail!("set WASMER_TOKEN or run 'wasmer login' first");
}

Try / catch

match env.client() {
    Ok(client) => client,
    Err(e) if e.to_string().contains("no token provided") => {
        eprintln!("Authenticate: wasmer login, --token=XXX, or WASMER_TOKEN env var");
        return Err(e);
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01). Data as JSON: /api/errors/3fa0a1f1b1a7e591. Report an issue: GitHub.