Код: Выделить всё
GET /api/v1/o/authorize/?client_id=&response_type=code&redirect_uri=http://127.0.0.1:5173/callback&code_challenge=&code_challenge_method=S256
step 2 : Frontend Bearge Code по адресу:
Код: Выделить всё
POST /api/v1/o/token/
бэкэнд отвечает с:
Код: Выделить всё
{
"access_token": "...",
"expires_in": 36000,
"refresh_token": "...", ← this is what I want to move into a cookie
...
}
Код: Выделить всё
# urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("api/v1/o/", include("oauth2_provider.urls", namespace="oauth2_provider")),
]
< /code>
# settings.py (snippets)
INSTALLED_APPS = [
...
'oauth2_provider',
'social_django',
'drf_social_oauth2',
]
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'social_core.backends.google.GoogleOAuth2',
'drf_social_oauth2.backends.DjangoOAuth2',
)
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = ''
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = ''
REST_FRAMEWORK = {
"DEFAULT_AUTHENTICATION_CLASSES": (
"oauth2_provider.contrib.rest_framework.OAuth2Authentication",
"drf_social_oauth2.authentication.SocialAuthentication",
),
}
LOGIN_REDIRECT_URL = "/"
- Pkce работает.
- Авторизация Google OAuth2 интегрирована с использованием Social-App Из пользователя Social_auth.extra_data.
Подробнее здесь: https://stackoverflow.com/questions/796 ... -pkce-flow