async def generate_auth_url_for_whitelabel(
        db: AsyncSession, white_label: schemas.WhiteLabel
    ) -> str:
        """Generate the OAuth2 authorization URL for a white label integration."""
        source = await crud.source.get_by_short_name(
            db=db, short_name=white_label.source_short_name
        )

        if not source:
            raise NotFoundException(f"Source not found: {white_label.source_short_name}")

        integration_config = await integration_settings.get_by_short_name(source.short_name)

        if not integration_config:
            raise NotFoundException("Integration not found")

        # Use white_label's redirect_url instead of the default one
        params = {
            "response_type": "code",
            "client_id": white_label.client_id,
            "redirect_uri": white_label.redirect_url,
            **(integration_config.additional_frontend_params or {}),
        }

        if integration_config.scope:
            params["scope"] = integration_config.scope

        auth_url = f"{integration_config.url}?{urlencode(params)}"
        return auth_url
Generate the OAuth2 authorization URL for a white label integration.
backend/airweave/platform/auth/services.py