Foundry376/Mailspring · error

Gmail profile request returned ${meResp.status} ${meResp.sta

Error message

Gmail profile request returned ${meResp.status} ${meResp.statusText}: ${JSON.stringify(me)}

What it means

Guard in buildGmailAccountFromAuthResponse: after successfully exchanging the OAuth code for tokens, the request to Google's userinfo endpoint returned a non-ok status. The access token was obtained but the account's email address could not be resolved, so account creation aborts; commonly an invalid/expired token or scope (email scope missing).

Source

Thrown at app/internal_packages/onboarding/lib/onboarding-helpers.ts:234

  /// Exchange code for an access token
  const { access_token, refresh_token } = await fetchPostWithFormBody<TokenResponse>(
    'https://www.googleapis.com/oauth2/v4/token',
    {
      code: code,
      client_id: GMAIL_CLIENT_ID,
      client_secret: GMAIL_CLIENT_SECRET,
      redirect_uri: `http://127.0.0.1:${LOCAL_SERVER_PORT}`,
      grant_type: 'authorization_code',
    }
  );

  // get the user's email address
  const meResp = await fetch('https://www.googleapis.com/oauth2/v1/userinfo?alt=json', {
    headers: { Authorization: `Bearer ${access_token}` },
  });
  const me = await meResp.json();
  if (!meResp.ok) {
    throw new Error(
      `Gmail profile request returned ${meResp.status} ${meResp.statusText}: ${JSON.stringify(me)}`
    );
  }
  const account = await expandAccountWithCommonSettings(
    new Account({
      name: me.name,
      emailAddress: me.email,
      provider: 'gmail',
      settings: {
        refresh_client_id: GMAIL_CLIENT_ID,
        refresh_token: refresh_token,
      },
    })
  );

  account.id = idForAccount(me.email, account.settings);

  // test the account locally to ensure the All Mail folder is enabled

View on GitHub (pinned to 648c685d60)

Solutions

  1. Ensure the requested OAuth scopes include the userinfo/email scope
  2. Retry the flow to get a fresh access token if it expired
  3. Log the embedded response body to identify the Google error code
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at app/internal_packages/onboarding/lib/onboarding-helpers.ts:234 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03). Data as JSON: /api/errors/e307256fbdca8a25. Report an issue: GitHub.