{"record":{"id":"316e43c7d5c734ae","repo":"wasmerio/wasmer","slug":"not-logged-in","errorCode":null,"errorMessage":"Not logged in!","messagePattern":"Not logged in!","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/cli/src/commands/auth/login/mod.rs","lineNumber":229,"sourceCode":"        config\n            .registry\n            .set_current_registry(registry.as_ref())\n            .await;\n        config.registry.set_login_token_for_registry(\n            &config.registry.get_current_registry(),\n            &token,\n            UpdateRegistry::Update,\n        );\n        let path = WasmerConfig::get_file_location(env.dir());\n        config.save(path)?;\n\n        // This will automatically read the config again, picking up the new edits.\n        let client = env.client()?;\n\n        wasmer_backend_api::query::current_user(&client)\n            .await?\n            .map(|v| v.username)\n            .ok_or_else(|| anyhow::anyhow!(\"Not logged in!\"))\n    }\n\n    pub(crate) fn get_wasmer_env(&self) -> WasmerEnv {\n        WasmerEnv::new(\n            self.wasmer_dir.clone(),\n            self.cache_dir.clone(),\n            self.token.clone(),\n            self.registry.clone(),\n        )\n    }\n}\n\n#[async_trait::async_trait]\nimpl AsyncCliCommand for Login {\n    type Output = ();\n\n    async fn run_async(self) -> Result<Self::Output, anyhow::Error> {\n        let env = self.get_wasmer_env();","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/wasmerio/wasmer/blob/8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5/lib/cli/src/commands/auth/login/mod.rs#L211-L247","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"// before\n$ wasmer login $TOKEN   # stale token from old registry\n// error: Not logged in!\n// after: point CLI at the matching registry, then login\n$ wasmer config set-registry registry.wasmer.io\n$ wasmer login $FRESH_TOKEN","handlingStrategy":"try-catch","validationCode":"// verify the token before saving it: curl the current_user query with the token\ncurl -fsS https://registry.wasmer.io/graphql -X POST \\\n  -H \"authorization: Bearer $TOKEN\" \\\n  -H 'content-type: application/json' \\\n  -d '{\"query\":\"{ viewer { username } }\"}'","typeGuard":null,"tryCatchPattern":"match wasmer_backend_api::query::current_user(&client).await {\n    Ok(Some(user)) => println!(\"logged in as {}\", user.username),\n    Ok(None) => anyhow::bail!(\"token rejected - generate a new one at https://wasmer.io/settings/access-tokens\"),\n    Err(e) => return Err(e.into()),\n}","preventionTips":["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."],"tags":["auth","login","token"],"backgroundTag":"invalid-auth-token","analyzedSha":"8c4b9ee9d33fb2068863fbb3d328683e7e6ff7f5","analyzedAt":"2026-09-01T23:06:31.009Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}