Files
sdb-back/app/services/oauth_providers/google.py
2025-06-28 18:30:30 +02:00

35 lines
1.0 KiB
Python

from typing import Any, Dict
from .base import OAuthProvider
class GoogleOAuthProvider(OAuthProvider):
"""Google OAuth provider implementation."""
@property
def name(self) -> str:
return "google"
@property
def display_name(self) -> str:
return "Google"
def get_client_config(self) -> Dict[str, Any]:
"""Return Google OAuth client configuration."""
return {
"server_metadata_url": "https://accounts.google.com/.well-known/openid-configuration",
"client_kwargs": {"scope": "openid email profile"},
}
def get_user_info(self, token: Dict[str, Any]) -> Dict[str, Any]:
"""Extract user information from Google OAuth token response."""
client = self.get_client()
user_info = client.userinfo(token=token)
return {
"id": user_info.get("sub"),
"email": user_info.get("email"),
"name": user_info.get("name"),
"picture": user_info.get("picture"),
}