INNER CODE UNIT · Python

get_github_primary_email

hunvreus/devpush · app/dependencies.py:59

async def get_github_primary_email(oauth_client: OAuth, token: dict) -> str | None:
    """Get user's primary verified email from GitHub."""
    try:
        if not oauth_client.github:
            return None

        response = await oauth_client.github.get("user/emails", token=token)
        emails = response.json()

        primary_email = next(
            (e for e in emails if e.get("primary") and e.get("verified")), None
        )
        return primary_email["email"] if primary_email else None
    except Exception:
        return None


@lru_cache

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…