52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
|
|
import os
|
||
|
|
from authlib.integrations.starlette_client import OAuth
|
||
|
|
from starlette.config import Config
|
||
|
|
|
||
|
|
# Load environment variables
|
||
|
|
config = Config('.env')
|
||
|
|
|
||
|
|
# Initialize OAuth
|
||
|
|
oauth = OAuth(config)
|
||
|
|
|
||
|
|
# Google OAuth Configuration
|
||
|
|
oauth.register(
|
||
|
|
name='google',
|
||
|
|
client_id=os.getenv('GOOGLE_CLIENT_ID'),
|
||
|
|
client_secret=os.getenv('GOOGLE_CLIENT_SECRET'),
|
||
|
|
server_metadata_url='https://accounts.google.com/.well-known/openid-configuration',
|
||
|
|
client_kwargs={
|
||
|
|
'scope': 'openid email profile'
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
# Facebook OAuth Configuration
|
||
|
|
oauth.register(
|
||
|
|
name='facebook',
|
||
|
|
client_id=os.getenv('FACEBOOK_APP_ID'),
|
||
|
|
client_secret=os.getenv('FACEBOOK_APP_SECRET'),
|
||
|
|
authorize_url='https://www.facebook.com/v12.0/dialog/oauth',
|
||
|
|
authorize_params=None,
|
||
|
|
access_token_url='https://graph.facebook.com/v12.0/oauth/access_token',
|
||
|
|
access_token_params=None,
|
||
|
|
refresh_token_url=None,
|
||
|
|
client_kwargs={
|
||
|
|
'scope': 'email public_profile',
|
||
|
|
'token_endpoint_auth_method': 'client_secret_post'
|
||
|
|
}
|
||
|
|
)
|
||
|
|
|
||
|
|
# Yahoo OAuth Configuration
|
||
|
|
oauth.register(
|
||
|
|
name='yahoo',
|
||
|
|
client_id=os.getenv('YAHOO_CLIENT_ID'),
|
||
|
|
client_secret=os.getenv('YAHOO_CLIENT_SECRET'),
|
||
|
|
authorize_url='https://api.login.yahoo.com/oauth2/request_auth',
|
||
|
|
authorize_params=None,
|
||
|
|
access_token_url='https://api.login.yahoo.com/oauth2/get_token',
|
||
|
|
access_token_params=None,
|
||
|
|
client_kwargs={
|
||
|
|
'scope': 'openid email profile',
|
||
|
|
'token_endpoint_auth_method': 'client_secret_post'
|
||
|
|
}
|
||
|
|
)
|