bitwarden/server · warning · BadRequestException
No teams were found.
Error message
No teams were found.
What it means
Thrown during the Teams OAuth callback after the token is obtained but teamsService.GetJoinedTeamsAsync returns an empty list. The authenticated Microsoft account has no Teams memberships to integrate with. BadRequestException returns HTTP 400, and the integration is not persisted.
Source
Thrown at src/Api/Dirt/Controllers/TeamsIntegrationController.cs:126
protocol: currentContext.HttpContext.Request.Scheme,
host: currentContext.HttpContext.Request.Host.ToUriComponent()
);
if (string.IsNullOrEmpty(callbackUrl))
{
throw new BadRequestException("Unable to build callback Url");
}
var token = await teamsService.ObtainTokenViaOAuth(code, callbackUrl);
if (string.IsNullOrEmpty(token))
{
throw new BadRequestException("Invalid response from Teams.");
}
var teams = await teamsService.GetJoinedTeamsAsync(token);
if (!teams.Any())
{
throw new BadRequestException("No teams were found.");
}
var teamsIntegration = new TeamsIntegration(TenantId: teams[0].TenantId, Teams: teams);
integration.Configuration = JsonSerializer.Serialize(teamsIntegration);
await integrationRepository.UpsertAsync(integration);
var location = $"/organizations/{integration.OrganizationId}/integrations/{integration.Id}";
return Created(location, new OrganizationIntegrationResponseModel(integration));
}
[Route("integrations/teams/incoming")]
[AllowAnonymous]
[HttpPost]
public async Task IncomingPostAsync()
{
await adapter.ProcessAsync(Request, Response, bot);
}
}View on GitHub (pinned to e93b962371)
Solutions
- Ensure the user signs in with a work/school Microsoft account that is a member of at least one Team.
- Verify the Azure AD app has the Team.ReadBasic.All (or equivalent) permission granted.
- Confirm Teams is enabled in the user's Microsoft 365 tenant.
- Provide a user-facing message prompting them to join or create a Team first.
Example fix
// before
var teams = await teamsService.GetJoinedTeamsAsync(token);
if (!teams.Any()) throw new BadRequestException("No teams were found.");
// after — actionable user message
var teams = await teamsService.GetJoinedTeamsAsync(token);
if (!teams.Any())
{
throw new BadRequestException("Your Microsoft account is not a member of any Teams. Join or create a Team in Microsoft Teams, then retry.");
} Defensive patterns
Strategy: validation
Validate before calling
// After token acquisition, check team membership before persisting
var teams = await _teamsService.GetJoinedTeamsAsync(token);
if (teams == null || !teams.Any())
return BadRequest("Your Microsoft account is not a member of any Teams. Join or create a Team, then retry."); Type guard
public static bool HasTeamMemberships(IReadOnlyList<TeamInfo> teams) =>
teams != null && teams.Count > 0; Try / catch
try
{
await _teamsService.CompleteOAuthAsync(code, state);
}
catch (BadRequestException ex) when (ex.Message.Contains("No teams"))
{
return BadRequest("No Teams found for your account. Ensure you are a member of at least one Microsoft Team.");
} Prevention
- Ensure users authorize with a work/school account that is a member of at least one Team.
- Verify the Azure AD app has Team.ReadBasic.All permission granted and admin-consented.
- Show a pre-connect UI message instructing users to join a Team first if they have none.
When it happens
Trigger: OAuth callback where the Microsoft account that authorized the app belongs to no Microsoft Teams teams. This can happen if the account is a personal Microsoft account, or an organizational account with no team memberships.
Common situations: User signs in with a personal Microsoft account instead of a work/school account; the organization has Teams disabled or the user hasn't been added to any team; the Teams service principal lacks permission to read the user's joined teams (Team.ReadBasic.All scope missing).
Related errors
- Invalid response from Teams.
- Unable to build callback Url
- There already exists a Teams integration for this organizati
- Resource not found.
- Unable to build callback Url
AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13).
Data as JSON: /api/errors/efd17dc9e794a1ff.
Report an issue: GitHub.