from django.urls import path, include from .views import SocialLoginView, SocialAuthCallbackView, SocialAuthSuccessView urlpatterns = [ # Python Social Auth URLs (MUST BE FIRST for OAuth redirect flow) # /api/v1/social/login/github/ - GET: Start GitHub OAuth # /api/v1/social/login/google-oauth2/ - GET: Start Google OAuth # /api/v1/social/complete/github/ - GET: GitHub callback (handled by social-auth) # /api/v1/social/complete/google-oauth2/ - GET: Google callback (handled by social-auth) path('social/', include('social_django.urls', namespace='social')), # SPA Test Page (Main app) path('spa/', lambda request: __import__('django.shortcuts').shortcuts.render( request, 'spa_test/index.html' ), name='spa-test'), # SPA Activation Page (Frontend route for email links) path('spa/activate///', lambda request, uid, token: __import__('django.shortcuts').shortcuts.render( request, 'spa_test/activate.html', {'uid': uid, 'token': token} ), name='spa-activate'), # Django REST Framework browsable API auth path('api-auth/', include('rest_framework.urls')), # Djoser endpoints (registration, activation, etc.) # /api/v1/auth/users/ - POST: Register new user # /api/v1/auth/users/activation/ - POST: Activate account with uid/token # /api/v1/auth/users/me/ - GET: Get current user info # /api/v1/auth/users/resend_activation/ - POST: Resend activation email path('auth/', include('djoser.urls')), # Djoser JWT endpoints # /api/v1/auth/jwt/create/ - POST: Login (get JWT tokens) # /api/v1/auth/jwt/refresh/ - POST: Refresh access token # /api/v1/auth/jwt/verify/ - POST: Verify token path('auth/', include('djoser.urls.jwt')), # Social authentication endpoints (Token-based - for mobile/SPA) # /api/v1/auth/social/google-oauth2/ - POST: Login with Google (requires access_token) # /api/v1/auth/social/github/ - POST: Login with GitHub (requires access_token) # /api/v1/auth/social/facebook/ - POST: Login with Facebook (requires access_token) path('auth/social//', SocialLoginView.as_view(), name='social-login'), # OAuth callback handler (after social-auth completes) path('auth/social/callback/', SocialAuthCallbackView.as_view(), name='social-callback'), # Success/Error pages path('auth/social/success/', SocialAuthSuccessView.as_view(), name='social-success'), ]