gitbutlerapp/gitbutler · error

No Bitbucket access token found for account '{account_id}'.\

Error message

No Bitbucket access token found for account '{account_id}'.\nRun 'but config forge auth' to re-authenticate.

What it means

BitbucketClient::from_storage resolved an account id but found no stored access token for it in forge storage, so no authenticated request is possible. The message names the account and prescribes the fix — `but config forge auth` — which reruns the OAuth flow and stores a fresh token. Missing here means absent from storage; an expired-but-present token instead surfaces later as an HTTP error.

Source

Thrown at crates/but-bitbucket/src/client.rs:64

            .default_headers(headers)
            .timeout(BITBUCKET_REQUEST_TIMEOUT)
            .build()?;

        Ok(Self {
            client,
            base_url: BITBUCKET_API_BASE_URL.to_string(),
        })
    }

    pub fn from_storage(
        storage: &but_forge_storage::Controller,
        preferred_account: Option<&crate::BitbucketAccountIdentifier>,
    ) -> Result<Self> {
        let account_id = resolve_account(preferred_account, storage)?;
        if let Some(access_token) = crate::token::get_bb_access_token(&account_id, storage)? {
            account_id.client(&access_token)
        } else {
            Err(anyhow::anyhow!(
                "No Bitbucket access token found for account '{account_id}'.\nRun 'but config forge auth' to re-authenticate."
            ))
        }
    }

    pub async fn get_authenticated(&self) -> Result<AuthenticatedUser> {
        let url = format!("{}/user", self.base_url);
        let response = self.client.get(&url).send().await?;

        if !response.status().is_success() {
            return Err(HttpStatusError {
                status: response.status(),
            }
            .into());
        }

        let user: BitbucketApiUser = response.json().await?;
        Ok(AuthenticatedUser {

View on GitHub (pinned to 2497b8007a)

Solutions

  1. Run `but config forge auth` for the named account and complete the flow.
  2. If several accounts are stored, pass the intended account identifier or remove stale accounts from forge storage.
  3. On macOS, unlock the keychain and allow the app access to its GitButler entries.
  4. Verify a token exists for the account before retrying the API call.

Example fix

# before: API call fails with "No Bitbucket access token found for account '...'"
but config forge auth   # rerun OAuth and store a new token
# then retry the original command/API call
Defensive patterns

Strategy: validation

Validate before calling

// Rust: probe storage before building the client
let account_id = resolve_account(preferred, storage)?;
if token::get_bb_access_token(&account_id, storage)?.is_none() {
    // route the user to `but config forge auth` instead of failing later
}

Try / catch

catch (e) {
  if (/No Bitbucket access token found/.test(String(e.message))) {
    return promptReauth('bitbucket', e.message.split("'")[1]);
  }
  throw e;
}

Prevention

When it happens

Trigger: Using any Bitbucket forge API before authenticating; after tokens were removed (logout, wiped data directory, OS keychain locked or entry deleted); when multiple accounts exist and resolve_account picked one that has no token.

Common situations: Fresh installs that skipped onboarding; macOS keychain access denied; migrated or reset data directories; switching accounts with a stale preferred account id.

Understand the failure class

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@2497b8007a (2026-08-17). Data as JSON: /api/errors/4aeeee137822e806. Report an issue: GitHub.