wasmerio/wasmer · error
Not logged in!
Error message
Not logged in!
What it means
After saving the login token, `login_and_save` re-opens an authenticated client and calls `current_user` to confirm and display who logged in. If the backend returns no user for the stored credentials, the CLI raises `Not logged in!`. It means the token that was just saved is not accepted as a valid session.
Source
Thrown at lib/cli/src/commands/auth/login/mod.rs:229
config
.registry
.set_current_registry(registry.as_ref())
.await;
config.registry.set_login_token_for_registry(
&config.registry.get_current_registry(),
&token,
UpdateRegistry::Update,
);
let path = WasmerConfig::get_file_location(env.dir());
config.save(path)?;
// This will automatically read the config again, picking up the new edits.
let client = env.client()?;
wasmer_backend_api::query::current_user(&client)
.await?
.map(|v| v.username)
.ok_or_else(|| anyhow::anyhow!("Not logged in!"))
}
pub(crate) fn get_wasmer_env(&self) -> WasmerEnv {
WasmerEnv::new(
self.wasmer_dir.clone(),
self.cache_dir.clone(),
self.token.clone(),
self.registry.clone(),
)
}
}
#[async_trait::async_trait]
impl AsyncCliCommand for Login {
type Output = ();
async fn run_async(self) -> Result<Self::Output, anyhow::Error> {
let env = self.get_wasmer_env();View on GitHub (pinned to 8c4b9ee9d3)
Solutions
- Generate a fresh token at https://wasmer.io/settings/access-tokens and retry `wasmer login <TOKEN>`.
- Confirm the token belongs to the registry the CLI is using (check `wasmer config get-registry` / --registry flag).
- Inspect ~/.wasmer/wasmer.toml for a stale token under the registry entry and clear it.
- Verify no trailing characters/newlines were introduced when copying the token.
Example fix
// before $ wasmer login $TOKEN # stale token from old registry // error: Not logged in! // after: point CLI at the matching registry, then login $ wasmer config set-registry registry.wasmer.io $ wasmer login $FRESH_TOKEN
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the token before saving it: curl the current_user query with the token
curl -fsS https://registry.wasmer.io/graphql -X POST \
-H "authorization: Bearer $TOKEN" \
-H 'content-type: application/json' \
-d '{"query":"{ viewer { username } }"}' Try / catch
match wasmer_backend_api::query::current_user(&client).await {
Ok(Some(user)) => println!("logged in as {}", user.username),
Ok(None) => anyhow::bail!("token rejected - generate a new one at https://wasmer.io/settings/access-tokens"),
Err(e) => return Err(e.into()),
} Prevention
- Always test freshly copied tokens for stray whitespace/newlines.
- Match the token to the registry you configure (`wasmer config set-registry`).
- Rotate tokens before expiry rather than reusing old ones.
When it happens
Trigger: `wasmer login <token>` completes the save, then `current_user(&client)` resolves to `None` — e.g. the token is invalid, revoked, expired, or scoped to a different registry than the one being queried.
Common situations: Pasting a malformed or whitespace-mangled token; token created for a different registry endpoint than env.registry_endpoint(); expired/revoked access token; clock skew affecting token validation.
Related errors
- The backend did not return any nonce to auth the login!
- ❌ Failed to receive token from localhost
- no token provided - run 'wasmer login', specify --token=XXX,
- config from file: {e}
- No registry not specified!
AI-assisted analysis of wasmerio/wasmer@8c4b9ee9d3 (2026-09-01).
Data as JSON: /api/errors/316e43c7d5c734ae.
Report an issue: GitHub.