Files
fastapi/app/core/oauth.py
Beyhan Oğur 361dbef019 first commit
2026-04-26 22:25:19 +03:00

28 lines
827 B
Python

from urllib.parse import urlencode
from typing import Dict
from app.core.config import settings
def google_authorize_url(state: str = "state") -> str:
params = {
"client_id": settings.GOOGLE_CLIENT_ID,
"redirect_uri": settings.GOOGLE_REDIRECT_URL,
"response_type": "code",
"scope": "openid email profile",
"state": state,
"access_type": "offline",
"prompt": "consent",
}
return "https://accounts.google.com/o/oauth2/v2/auth?" + urlencode(params)
def github_authorize_url(state: str = "state") -> str:
params = {
"client_id": settings.GITHUB_CLIENT_ID,
"redirect_uri": settings.GITHUB_REDIRECT_URL,
"scope": "user:email",
"state": state,
}
return "https://github.com/login/oauth/authorize?" + urlencode(params)